{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np # 数据处理最重要的模块\n",
    "import pandas as pd # 数据处理最重要的模块\n",
    "import scipy.stats as stats # 统计模块\n",
    "import scipy\n",
    "# import pymysql  # 导入数据库模块\n",
    "\n",
    "from datetime import datetime # 时间模块\n",
    "import statsmodels.formula.api as smf  # OLS regression\n",
    "\n",
    "# import pyreadr # read RDS file\n",
    "\n",
    "from matplotlib import style\n",
    "import matplotlib.pyplot as plt  # 画图模块\n",
    "import matplotlib.dates as mdates\n",
    "\n",
    "from matplotlib.font_manager import FontProperties # 作图中文\n",
    "from pylab import mpl\n",
    "#mpl.rcParams['font.sans-serif'] = ['SimHei']\n",
    "#plt.rcParams['font.family'] = 'Times New Roman'\n",
    "\n",
    "from pandas.tseries.offsets import MonthEnd\n",
    "\n",
    "#输出矢量图 渲染矢量图\n",
    "%matplotlib inline\n",
    "%config InlineBackend.figure_format = 'svg'\n",
    "\n",
    "from IPython.core.interactiveshell import InteractiveShell # jupyter运行输出的模块\n",
    "#显示每一个运行结果\n",
    "InteractiveShell.ast_node_interactivity = 'all'\n",
    "\n",
    "#设置行不限制数量\n",
    "#pd.set_option('display.max_rows',None)\n",
    "\n",
    "#设置列不限制数量\n",
    "pd.set_option('display.max_columns', None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Stkcd</th>\n",
       "      <th>month</th>\n",
       "      <th>price</th>\n",
       "      <th>Rank</th>\n",
       "      <th>Freq</th>\n",
       "      <th>floatingvalue</th>\n",
       "      <th>totalvalue</th>\n",
       "      <th>sizef</th>\n",
       "      <th>sizet</th>\n",
       "      <th>Return</th>\n",
       "      <th>rfmonth</th>\n",
       "      <th>ret</th>\n",
       "      <th>next_ret</th>\n",
       "      <th>w</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-05-31</td>\n",
       "      <td>38.34</td>\n",
       "      <td>2</td>\n",
       "      <td>24.0</td>\n",
       "      <td>1.016010e+09</td>\n",
       "      <td>1.859497e+09</td>\n",
       "      <td>20.739149</td>\n",
       "      <td>21.343572</td>\n",
       "      <td>-0.122253</td>\n",
       "      <td>0.006092</td>\n",
       "      <td>-0.128345</td>\n",
       "      <td>-0.119551</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-06-30</td>\n",
       "      <td>33.99</td>\n",
       "      <td>3</td>\n",
       "      <td>23.0</td>\n",
       "      <td>9.007350e+08</td>\n",
       "      <td>1.648521e+09</td>\n",
       "      <td>20.618722</td>\n",
       "      <td>21.223144</td>\n",
       "      <td>-0.113459</td>\n",
       "      <td>0.006092</td>\n",
       "      <td>-0.119551</td>\n",
       "      <td>-0.137013</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-07-31</td>\n",
       "      <td>29.54</td>\n",
       "      <td>4</td>\n",
       "      <td>16.0</td>\n",
       "      <td>7.828100e+08</td>\n",
       "      <td>1.432695e+09</td>\n",
       "      <td>20.478401</td>\n",
       "      <td>21.082823</td>\n",
       "      <td>-0.130921</td>\n",
       "      <td>0.006092</td>\n",
       "      <td>-0.137013</td>\n",
       "      <td>-0.417680</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-08-31</td>\n",
       "      <td>15.00</td>\n",
       "      <td>5</td>\n",
       "      <td>15.0</td>\n",
       "      <td>6.748338e+08</td>\n",
       "      <td>1.346275e+09</td>\n",
       "      <td>20.329977</td>\n",
       "      <td>21.020607</td>\n",
       "      <td>-0.411588</td>\n",
       "      <td>0.006092</td>\n",
       "      <td>-0.417680</td>\n",
       "      <td>-0.039425</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-09-30</td>\n",
       "      <td>14.50</td>\n",
       "      <td>6</td>\n",
       "      <td>24.0</td>\n",
       "      <td>6.523394e+08</td>\n",
       "      <td>1.301399e+09</td>\n",
       "      <td>20.296075</td>\n",
       "      <td>20.986706</td>\n",
       "      <td>-0.033333</td>\n",
       "      <td>0.006092</td>\n",
       "      <td>-0.039425</td>\n",
       "      <td>0.849080</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752023</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-08-31</td>\n",
       "      <td>13.56</td>\n",
       "      <td>24</td>\n",
       "      <td>23.0</td>\n",
       "      <td>7.955351e+09</td>\n",
       "      <td>1.054667e+10</td>\n",
       "      <td>22.797111</td>\n",
       "      <td>23.079076</td>\n",
       "      <td>-0.025862</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027103</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752024</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-09-30</td>\n",
       "      <td>14.54</td>\n",
       "      <td>25</td>\n",
       "      <td>20.0</td>\n",
       "      <td>8.530295e+09</td>\n",
       "      <td>1.130889e+10</td>\n",
       "      <td>22.866890</td>\n",
       "      <td>23.148855</td>\n",
       "      <td>0.072271</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752025</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>13.85</td>\n",
       "      <td>26</td>\n",
       "      <td>17.0</td>\n",
       "      <td>8.125488e+09</td>\n",
       "      <td>1.077222e+10</td>\n",
       "      <td>22.818272</td>\n",
       "      <td>23.100237</td>\n",
       "      <td>-0.047455</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752026</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-11-30</td>\n",
       "      <td>13.48</td>\n",
       "      <td>27</td>\n",
       "      <td>22.0</td>\n",
       "      <td>7.908417e+09</td>\n",
       "      <td>1.048444e+10</td>\n",
       "      <td>22.791193</td>\n",
       "      <td>23.073159</td>\n",
       "      <td>-0.026715</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752027</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-12-31</td>\n",
       "      <td>14.89</td>\n",
       "      <td>28</td>\n",
       "      <td>21.0</td>\n",
       "      <td>8.735632e+09</td>\n",
       "      <td>1.158111e+10</td>\n",
       "      <td>22.890676</td>\n",
       "      <td>23.172641</td>\n",
       "      <td>0.104599</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>709883 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Stkcd      month  price  Rank  Freq  floatingvalue    totalvalue  \\\n",
       "1       000001 1991-05-31  38.34     2  24.0   1.016010e+09  1.859497e+09   \n",
       "2       000001 1991-06-30  33.99     3  23.0   9.007350e+08  1.648521e+09   \n",
       "3       000001 1991-07-31  29.54     4  16.0   7.828100e+08  1.432695e+09   \n",
       "4       000001 1991-08-31  15.00     5  15.0   6.748338e+08  1.346275e+09   \n",
       "5       000001 1991-09-30  14.50     6  24.0   6.523394e+08  1.301399e+09   \n",
       "...        ...        ...    ...   ...   ...            ...           ...   \n",
       "752023  605599 2023-08-31  13.56    24  23.0   7.955351e+09  1.054667e+10   \n",
       "752024  605599 2023-09-30  14.54    25  20.0   8.530295e+09  1.130889e+10   \n",
       "752025  605599 2023-10-31  13.85    26  17.0   8.125488e+09  1.077222e+10   \n",
       "752026  605599 2023-11-30  13.48    27  22.0   7.908417e+09  1.048444e+10   \n",
       "752027  605599 2023-12-31  14.89    28  21.0   8.735632e+09  1.158111e+10   \n",
       "\n",
       "            sizef      sizet    Return   rfmonth       ret  next_ret  w  \n",
       "1       20.739149  21.343572 -0.122253  0.006092 -0.128345 -0.119551  1  \n",
       "2       20.618722  21.223144 -0.113459  0.006092 -0.119551 -0.137013  1  \n",
       "3       20.478401  21.082823 -0.130921  0.006092 -0.137013 -0.417680  1  \n",
       "4       20.329977  21.020607 -0.411588  0.006092 -0.417680 -0.039425  1  \n",
       "5       20.296075  20.986706 -0.033333  0.006092 -0.039425  0.849080  1  \n",
       "...           ...        ...       ...       ...       ...       ... ..  \n",
       "752023  22.797111  23.079076 -0.025862  0.001241 -0.027103  0.071030  1  \n",
       "752024  22.866890  23.148855  0.072271  0.001241  0.071030 -0.048696  1  \n",
       "752025  22.818272  23.100237 -0.047455  0.001241 -0.048696 -0.027956  1  \n",
       "752026  22.791193  23.073159 -0.026715  0.001241 -0.027956  0.103358  1  \n",
       "752027  22.890676  23.172641  0.104599  0.001241  0.103358       NaN  1  \n",
       "\n",
       "[709883 rows x 14 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cross = pd.read_csv(r\"D:\\桌面\\ret_mon_python2023.csv\")\n",
    "from pandas.tseries.offsets import MonthEnd\n",
    "cross['month'] = pd.to_datetime(cross['month'], format='%Y-%m-%d') + MonthEnd(1)\n",
    "# 补齐股票代码 如果不满6位 在前面补上0\n",
    "cross['Stkcd'] = cross['Stkcd'].apply(lambda x: '{:0>6}'.format(x)) # 6位股票代码\n",
    "cross['w'] = 1\n",
    "cross = cross.dropna(subset=['ret','totalvalue'])\n",
    "cross"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Stkcd</th>\n",
       "      <th>month</th>\n",
       "      <th>ep</th>\n",
       "      <th>ep_recent</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-04-30</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-05-31</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-06-30</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-07-31</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000001</td>\n",
       "      <td>1991-08-31</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752023</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-08-31</td>\n",
       "      <td>0.054878</td>\n",
       "      <td>0.036802</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752024</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-09-30</td>\n",
       "      <td>0.051179</td>\n",
       "      <td>0.034322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752025</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>0.058164</td>\n",
       "      <td>0.050524</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752026</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-11-30</td>\n",
       "      <td>0.059760</td>\n",
       "      <td>0.051910</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>752027</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-12-31</td>\n",
       "      <td>0.054101</td>\n",
       "      <td>0.046995</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>752028 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Stkcd      month        ep  ep_recent\n",
       "0       000001 1991-04-30       NaN        NaN\n",
       "1       000001 1991-05-31       NaN        NaN\n",
       "2       000001 1991-06-30       NaN        NaN\n",
       "3       000001 1991-07-31       NaN        NaN\n",
       "4       000001 1991-08-31       NaN        NaN\n",
       "...        ...        ...       ...        ...\n",
       "752023  605599 2023-08-31  0.054878   0.036802\n",
       "752024  605599 2023-09-30  0.051179   0.034322\n",
       "752025  605599 2023-10-31  0.058164   0.050524\n",
       "752026  605599 2023-11-30  0.059760   0.051910\n",
       "752027  605599 2023-12-31  0.054101   0.046995\n",
       "\n",
       "[752028 rows x 4 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "EP = pd.read_csv(r\"D:\\桌面\\EP2023.csv\")\n",
    "EP['month'] = pd.to_datetime(EP['month'], format='%Y-%m-%d') + MonthEnd(1)\n",
    "EP = EP[['Stkcd','month','ep','ep_recent']]\n",
    "EP['Stkcd'] = EP['Stkcd'].apply(lambda x: '{:0>6}'.format(x)) # 6位股票代码\n",
    "EP"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Stkcd</th>\n",
       "      <th>month</th>\n",
       "      <th>price</th>\n",
       "      <th>Rank</th>\n",
       "      <th>Freq</th>\n",
       "      <th>floatingvalue</th>\n",
       "      <th>totalvalue</th>\n",
       "      <th>sizef</th>\n",
       "      <th>sizet</th>\n",
       "      <th>Return</th>\n",
       "      <th>rfmonth</th>\n",
       "      <th>ret</th>\n",
       "      <th>next_ret</th>\n",
       "      <th>w</th>\n",
       "      <th>ep</th>\n",
       "      <th>ep_recent</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-03-31</td>\n",
       "      <td>15.05</td>\n",
       "      <td>36</td>\n",
       "      <td>23.0</td>\n",
       "      <td>2.184334e+09</td>\n",
       "      <td>4.054739e+09</td>\n",
       "      <td>21.504577</td>\n",
       "      <td>22.123152</td>\n",
       "      <td>-0.170799</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.179518</td>\n",
       "      <td>0.053739</td>\n",
       "      <td>1</td>\n",
       "      <td>0.067405</td>\n",
       "      <td>0.067405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-04-30</td>\n",
       "      <td>15.99</td>\n",
       "      <td>37</td>\n",
       "      <td>21.0</td>\n",
       "      <td>2.320765e+09</td>\n",
       "      <td>4.307992e+09</td>\n",
       "      <td>21.565163</td>\n",
       "      <td>22.183738</td>\n",
       "      <td>0.062458</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>0.053739</td>\n",
       "      <td>-0.095648</td>\n",
       "      <td>1</td>\n",
       "      <td>0.063443</td>\n",
       "      <td>0.063443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-05-31</td>\n",
       "      <td>14.60</td>\n",
       "      <td>38</td>\n",
       "      <td>21.0</td>\n",
       "      <td>2.119022e+09</td>\n",
       "      <td>3.933501e+09</td>\n",
       "      <td>21.474221</td>\n",
       "      <td>22.092796</td>\n",
       "      <td>-0.086929</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.095648</td>\n",
       "      <td>-0.088171</td>\n",
       "      <td>1</td>\n",
       "      <td>0.069483</td>\n",
       "      <td>0.069483</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-06-30</td>\n",
       "      <td>13.44</td>\n",
       "      <td>39</td>\n",
       "      <td>22.0</td>\n",
       "      <td>2.407403e+09</td>\n",
       "      <td>3.620977e+09</td>\n",
       "      <td>21.601814</td>\n",
       "      <td>22.010010</td>\n",
       "      <td>-0.079452</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.088171</td>\n",
       "      <td>-0.056046</td>\n",
       "      <td>1</td>\n",
       "      <td>0.075480</td>\n",
       "      <td>0.075480</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-07-31</td>\n",
       "      <td>8.00</td>\n",
       "      <td>40</td>\n",
       "      <td>18.0</td>\n",
       "      <td>2.292765e+09</td>\n",
       "      <td>3.448549e+09</td>\n",
       "      <td>21.553024</td>\n",
       "      <td>21.961219</td>\n",
       "      <td>-0.047327</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.056046</td>\n",
       "      <td>0.553781</td>\n",
       "      <td>1</td>\n",
       "      <td>0.079254</td>\n",
       "      <td>0.079254</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>709878</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-08-31</td>\n",
       "      <td>13.56</td>\n",
       "      <td>24</td>\n",
       "      <td>23.0</td>\n",
       "      <td>7.955351e+09</td>\n",
       "      <td>1.054667e+10</td>\n",
       "      <td>22.797111</td>\n",
       "      <td>23.079076</td>\n",
       "      <td>-0.025862</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027103</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054878</td>\n",
       "      <td>0.036802</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>709879</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-09-30</td>\n",
       "      <td>14.54</td>\n",
       "      <td>25</td>\n",
       "      <td>20.0</td>\n",
       "      <td>8.530295e+09</td>\n",
       "      <td>1.130889e+10</td>\n",
       "      <td>22.866890</td>\n",
       "      <td>23.148855</td>\n",
       "      <td>0.072271</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>1</td>\n",
       "      <td>0.051179</td>\n",
       "      <td>0.034322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>709880</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>13.85</td>\n",
       "      <td>26</td>\n",
       "      <td>17.0</td>\n",
       "      <td>8.125488e+09</td>\n",
       "      <td>1.077222e+10</td>\n",
       "      <td>22.818272</td>\n",
       "      <td>23.100237</td>\n",
       "      <td>-0.047455</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>1</td>\n",
       "      <td>0.058164</td>\n",
       "      <td>0.050524</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>709881</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-11-30</td>\n",
       "      <td>13.48</td>\n",
       "      <td>27</td>\n",
       "      <td>22.0</td>\n",
       "      <td>7.908417e+09</td>\n",
       "      <td>1.048444e+10</td>\n",
       "      <td>22.791193</td>\n",
       "      <td>23.073159</td>\n",
       "      <td>-0.026715</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>1</td>\n",
       "      <td>0.059760</td>\n",
       "      <td>0.051910</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>709882</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-12-31</td>\n",
       "      <td>14.89</td>\n",
       "      <td>28</td>\n",
       "      <td>21.0</td>\n",
       "      <td>8.735632e+09</td>\n",
       "      <td>1.158111e+10</td>\n",
       "      <td>22.890676</td>\n",
       "      <td>23.172641</td>\n",
       "      <td>0.104599</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054101</td>\n",
       "      <td>0.046995</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>624127 rows × 16 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Stkcd      month  price  Rank  Freq  floatingvalue    totalvalue  \\\n",
       "34      000001 1994-03-31  15.05    36  23.0   2.184334e+09  4.054739e+09   \n",
       "35      000001 1994-04-30  15.99    37  21.0   2.320765e+09  4.307992e+09   \n",
       "36      000001 1994-05-31  14.60    38  21.0   2.119022e+09  3.933501e+09   \n",
       "37      000001 1994-06-30  13.44    39  22.0   2.407403e+09  3.620977e+09   \n",
       "38      000001 1994-07-31   8.00    40  18.0   2.292765e+09  3.448549e+09   \n",
       "...        ...        ...    ...   ...   ...            ...           ...   \n",
       "709878  605599 2023-08-31  13.56    24  23.0   7.955351e+09  1.054667e+10   \n",
       "709879  605599 2023-09-30  14.54    25  20.0   8.530295e+09  1.130889e+10   \n",
       "709880  605599 2023-10-31  13.85    26  17.0   8.125488e+09  1.077222e+10   \n",
       "709881  605599 2023-11-30  13.48    27  22.0   7.908417e+09  1.048444e+10   \n",
       "709882  605599 2023-12-31  14.89    28  21.0   8.735632e+09  1.158111e+10   \n",
       "\n",
       "            sizef      sizet    Return   rfmonth       ret  next_ret  w  \\\n",
       "34      21.504577  22.123152 -0.170799  0.008719 -0.179518  0.053739  1   \n",
       "35      21.565163  22.183738  0.062458  0.008719  0.053739 -0.095648  1   \n",
       "36      21.474221  22.092796 -0.086929  0.008719 -0.095648 -0.088171  1   \n",
       "37      21.601814  22.010010 -0.079452  0.008719 -0.088171 -0.056046  1   \n",
       "38      21.553024  21.961219 -0.047327  0.008719 -0.056046  0.553781  1   \n",
       "...           ...        ...       ...       ...       ...       ... ..   \n",
       "709878  22.797111  23.079076 -0.025862  0.001241 -0.027103  0.071030  1   \n",
       "709879  22.866890  23.148855  0.072271  0.001241  0.071030 -0.048696  1   \n",
       "709880  22.818272  23.100237 -0.047455  0.001241 -0.048696 -0.027956  1   \n",
       "709881  22.791193  23.073159 -0.026715  0.001241 -0.027956  0.103358  1   \n",
       "709882  22.890676  23.172641  0.104599  0.001241  0.103358       NaN  1   \n",
       "\n",
       "              ep  ep_recent  \n",
       "34      0.067405   0.067405  \n",
       "35      0.063443   0.063443  \n",
       "36      0.069483   0.069483  \n",
       "37      0.075480   0.075480  \n",
       "38      0.079254   0.079254  \n",
       "...          ...        ...  \n",
       "709878  0.054878   0.036802  \n",
       "709879  0.051179   0.034322  \n",
       "709880  0.058164   0.050524  \n",
       "709881  0.059760   0.051910  \n",
       "709882  0.054101   0.046995  \n",
       "\n",
       "[624127 rows x 16 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cross = pd.merge(cross, EP, on=['Stkcd','month'], how='left')\n",
    "cross = cross.dropna(subset=['ep','ep_recent'])\n",
    "cross"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 删除30%（中国情况）去除小公司的包壳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>fenweishu_guimo</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>month</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1991-01-31</th>\n",
       "      <td>1.159622e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-02-28</th>\n",
       "      <td>5.505114e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-03-31</th>\n",
       "      <td>3.377500e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-04-30</th>\n",
       "      <td>3.222500e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-05-31</th>\n",
       "      <td>3.002500e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-08-31</th>\n",
       "      <td>3.756695e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-09-30</th>\n",
       "      <td>3.756347e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-10-31</th>\n",
       "      <td>3.736221e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-11-30</th>\n",
       "      <td>3.908821e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-12-31</th>\n",
       "      <td>3.845193e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>396 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            fenweishu_guimo\n",
       "month                      \n",
       "1991-01-31     1.159622e+08\n",
       "1991-02-28     5.505114e+07\n",
       "1991-03-31     3.377500e+07\n",
       "1991-04-30     3.222500e+07\n",
       "1991-05-31     3.002500e+07\n",
       "...                     ...\n",
       "2023-08-31     3.756695e+09\n",
       "2023-09-30     3.756347e+09\n",
       "2023-10-31     3.736221e+09\n",
       "2023-11-30     3.908821e+09\n",
       "2023-12-31     3.845193e+09\n",
       "\n",
       "[396 rows x 1 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fenweishu = pd.DataFrame(\n",
    "    cross.groupby(['month'])['totalvalue'].quantile(0.3))\n",
    "fenweishu.columns = ['fenweishu_guimo']\n",
    "fenweishu\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Stkcd</th>\n",
       "      <th>month</th>\n",
       "      <th>price</th>\n",
       "      <th>Rank</th>\n",
       "      <th>Freq</th>\n",
       "      <th>floatingvalue</th>\n",
       "      <th>totalvalue</th>\n",
       "      <th>sizef</th>\n",
       "      <th>sizet</th>\n",
       "      <th>Return</th>\n",
       "      <th>rfmonth</th>\n",
       "      <th>ret</th>\n",
       "      <th>next_ret</th>\n",
       "      <th>w</th>\n",
       "      <th>ep</th>\n",
       "      <th>ep_recent</th>\n",
       "      <th>fenweishu_guimo</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-03-31</td>\n",
       "      <td>15.05</td>\n",
       "      <td>36</td>\n",
       "      <td>23.0</td>\n",
       "      <td>2.184334e+09</td>\n",
       "      <td>4.054739e+09</td>\n",
       "      <td>21.504577</td>\n",
       "      <td>22.123152</td>\n",
       "      <td>-0.170799</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.179518</td>\n",
       "      <td>0.053739</td>\n",
       "      <td>1</td>\n",
       "      <td>0.067405</td>\n",
       "      <td>0.067405</td>\n",
       "      <td>7.076385e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-04-30</td>\n",
       "      <td>15.99</td>\n",
       "      <td>37</td>\n",
       "      <td>21.0</td>\n",
       "      <td>2.320765e+09</td>\n",
       "      <td>4.307992e+09</td>\n",
       "      <td>21.565163</td>\n",
       "      <td>22.183738</td>\n",
       "      <td>0.062458</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>0.053739</td>\n",
       "      <td>-0.095648</td>\n",
       "      <td>1</td>\n",
       "      <td>0.063443</td>\n",
       "      <td>0.063443</td>\n",
       "      <td>5.862432e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-05-31</td>\n",
       "      <td>14.60</td>\n",
       "      <td>38</td>\n",
       "      <td>21.0</td>\n",
       "      <td>2.119022e+09</td>\n",
       "      <td>3.933501e+09</td>\n",
       "      <td>21.474221</td>\n",
       "      <td>22.092796</td>\n",
       "      <td>-0.086929</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.095648</td>\n",
       "      <td>-0.088171</td>\n",
       "      <td>1</td>\n",
       "      <td>0.069483</td>\n",
       "      <td>0.069483</td>\n",
       "      <td>6.211901e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-06-30</td>\n",
       "      <td>13.44</td>\n",
       "      <td>39</td>\n",
       "      <td>22.0</td>\n",
       "      <td>2.407403e+09</td>\n",
       "      <td>3.620977e+09</td>\n",
       "      <td>21.601814</td>\n",
       "      <td>22.010010</td>\n",
       "      <td>-0.079452</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.088171</td>\n",
       "      <td>-0.056046</td>\n",
       "      <td>1</td>\n",
       "      <td>0.075480</td>\n",
       "      <td>0.075480</td>\n",
       "      <td>4.647960e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-07-31</td>\n",
       "      <td>8.00</td>\n",
       "      <td>40</td>\n",
       "      <td>18.0</td>\n",
       "      <td>2.292765e+09</td>\n",
       "      <td>3.448549e+09</td>\n",
       "      <td>21.553024</td>\n",
       "      <td>21.961219</td>\n",
       "      <td>-0.047327</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.056046</td>\n",
       "      <td>0.553781</td>\n",
       "      <td>1</td>\n",
       "      <td>0.079254</td>\n",
       "      <td>0.079254</td>\n",
       "      <td>3.490603e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>624122</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-08-31</td>\n",
       "      <td>13.56</td>\n",
       "      <td>24</td>\n",
       "      <td>23.0</td>\n",
       "      <td>7.955351e+09</td>\n",
       "      <td>1.054667e+10</td>\n",
       "      <td>22.797111</td>\n",
       "      <td>23.079076</td>\n",
       "      <td>-0.025862</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027103</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054878</td>\n",
       "      <td>0.036802</td>\n",
       "      <td>3.756695e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>624123</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-09-30</td>\n",
       "      <td>14.54</td>\n",
       "      <td>25</td>\n",
       "      <td>20.0</td>\n",
       "      <td>8.530295e+09</td>\n",
       "      <td>1.130889e+10</td>\n",
       "      <td>22.866890</td>\n",
       "      <td>23.148855</td>\n",
       "      <td>0.072271</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>1</td>\n",
       "      <td>0.051179</td>\n",
       "      <td>0.034322</td>\n",
       "      <td>3.756347e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>624124</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>13.85</td>\n",
       "      <td>26</td>\n",
       "      <td>17.0</td>\n",
       "      <td>8.125488e+09</td>\n",
       "      <td>1.077222e+10</td>\n",
       "      <td>22.818272</td>\n",
       "      <td>23.100237</td>\n",
       "      <td>-0.047455</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>1</td>\n",
       "      <td>0.058164</td>\n",
       "      <td>0.050524</td>\n",
       "      <td>3.736221e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>624125</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-11-30</td>\n",
       "      <td>13.48</td>\n",
       "      <td>27</td>\n",
       "      <td>22.0</td>\n",
       "      <td>7.908417e+09</td>\n",
       "      <td>1.048444e+10</td>\n",
       "      <td>22.791193</td>\n",
       "      <td>23.073159</td>\n",
       "      <td>-0.026715</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>1</td>\n",
       "      <td>0.059760</td>\n",
       "      <td>0.051910</td>\n",
       "      <td>3.908821e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>624126</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-12-31</td>\n",
       "      <td>14.89</td>\n",
       "      <td>28</td>\n",
       "      <td>21.0</td>\n",
       "      <td>8.735632e+09</td>\n",
       "      <td>1.158111e+10</td>\n",
       "      <td>22.890676</td>\n",
       "      <td>23.172641</td>\n",
       "      <td>0.104599</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054101</td>\n",
       "      <td>0.046995</td>\n",
       "      <td>3.845193e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>436794 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Stkcd      month  price  Rank  Freq  floatingvalue    totalvalue  \\\n",
       "0       000001 1994-03-31  15.05    36  23.0   2.184334e+09  4.054739e+09   \n",
       "1       000001 1994-04-30  15.99    37  21.0   2.320765e+09  4.307992e+09   \n",
       "2       000001 1994-05-31  14.60    38  21.0   2.119022e+09  3.933501e+09   \n",
       "3       000001 1994-06-30  13.44    39  22.0   2.407403e+09  3.620977e+09   \n",
       "4       000001 1994-07-31   8.00    40  18.0   2.292765e+09  3.448549e+09   \n",
       "...        ...        ...    ...   ...   ...            ...           ...   \n",
       "624122  605599 2023-08-31  13.56    24  23.0   7.955351e+09  1.054667e+10   \n",
       "624123  605599 2023-09-30  14.54    25  20.0   8.530295e+09  1.130889e+10   \n",
       "624124  605599 2023-10-31  13.85    26  17.0   8.125488e+09  1.077222e+10   \n",
       "624125  605599 2023-11-30  13.48    27  22.0   7.908417e+09  1.048444e+10   \n",
       "624126  605599 2023-12-31  14.89    28  21.0   8.735632e+09  1.158111e+10   \n",
       "\n",
       "            sizef      sizet    Return   rfmonth       ret  next_ret  w  \\\n",
       "0       21.504577  22.123152 -0.170799  0.008719 -0.179518  0.053739  1   \n",
       "1       21.565163  22.183738  0.062458  0.008719  0.053739 -0.095648  1   \n",
       "2       21.474221  22.092796 -0.086929  0.008719 -0.095648 -0.088171  1   \n",
       "3       21.601814  22.010010 -0.079452  0.008719 -0.088171 -0.056046  1   \n",
       "4       21.553024  21.961219 -0.047327  0.008719 -0.056046  0.553781  1   \n",
       "...           ...        ...       ...       ...       ...       ... ..   \n",
       "624122  22.797111  23.079076 -0.025862  0.001241 -0.027103  0.071030  1   \n",
       "624123  22.866890  23.148855  0.072271  0.001241  0.071030 -0.048696  1   \n",
       "624124  22.818272  23.100237 -0.047455  0.001241 -0.048696 -0.027956  1   \n",
       "624125  22.791193  23.073159 -0.026715  0.001241 -0.027956  0.103358  1   \n",
       "624126  22.890676  23.172641  0.104599  0.001241  0.103358       NaN  1   \n",
       "\n",
       "              ep  ep_recent  fenweishu_guimo  \n",
       "0       0.067405   0.067405     7.076385e+08  \n",
       "1       0.063443   0.063443     5.862432e+08  \n",
       "2       0.069483   0.069483     6.211901e+08  \n",
       "3       0.075480   0.075480     4.647960e+08  \n",
       "4       0.079254   0.079254     3.490603e+08  \n",
       "...          ...        ...              ...  \n",
       "624122  0.054878   0.036802     3.756695e+09  \n",
       "624123  0.051179   0.034322     3.756347e+09  \n",
       "624124  0.058164   0.050524     3.736221e+09  \n",
       "624125  0.059760   0.051910     3.908821e+09  \n",
       "624126  0.054101   0.046995     3.845193e+09  \n",
       "\n",
       "[436794 rows x 17 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cross_new = pd.merge(cross,fenweishu,on='month',how='left')\n",
    "cross_new = cross_new[cross_new['totalvalue'] > cross_new['fenweishu_guimo']]\n",
    "cross_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 删除交易日较少的股票"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "def calc_past_12m_freq(data, window_months=12):\n",
    "    \"\"\"\n",
    "    计算每个股票每月过去12个月的交易频率之和\n",
    "    \n",
    "    参数:\n",
    "    data: DataFrame, 需要包含 ['Stkcd', 'month', 'Freq'] 列\n",
    "    window_months: int, 回看的月份数，默认12个月\n",
    "    \n",
    "    返回:\n",
    "    DataFrame 包含 ['Stkcd', 'month', 'N12m'] 列\n",
    "    \"\"\"\n",
    "    results = []\n",
    "    \n",
    "    # 按股票分组计算\n",
    "    for stkcd, group in data.groupby('Stkcd'):\n",
    "        # 对每个股票的数据按时间排序\n",
    "        group = group.sort_values('month')\n",
    "        \n",
    "        # 对每个月份计算过去12个月的交易频率之和\n",
    "        for i in range(len(group)):\n",
    "            current_date = group['month'].iloc[i]\n",
    "            start_date = current_date - pd.DateOffset(months=window_months-1)  # 往前推11个月(加上当月共12个月)\n",
    "            \n",
    "            # 获取时间窗口内的数据\n",
    "            mask = (group['month'] >= start_date) & (group['month'] <= current_date)\n",
    "            freq_sum = group.loc[mask, 'Freq'].sum()\n",
    "            \n",
    "            results.append({\n",
    "                'Stkcd': stkcd,\n",
    "                'month': current_date,\n",
    "                'N12m': freq_sum\n",
    "            })\n",
    "    \n",
    "    return pd.DataFrame(results)\n",
    "\n",
    "# 使用方法\n",
    "freq_sums = calc_past_12m_freq(cross)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Stkcd</th>\n",
       "      <th>month</th>\n",
       "      <th>price</th>\n",
       "      <th>Rank</th>\n",
       "      <th>Freq</th>\n",
       "      <th>floatingvalue</th>\n",
       "      <th>totalvalue</th>\n",
       "      <th>sizef</th>\n",
       "      <th>sizet</th>\n",
       "      <th>Return</th>\n",
       "      <th>rfmonth</th>\n",
       "      <th>ret</th>\n",
       "      <th>next_ret</th>\n",
       "      <th>w</th>\n",
       "      <th>ep</th>\n",
       "      <th>ep_recent</th>\n",
       "      <th>fenweishu_guimo</th>\n",
       "      <th>N12m</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-03-31</td>\n",
       "      <td>15.05</td>\n",
       "      <td>36</td>\n",
       "      <td>23.0</td>\n",
       "      <td>2.184334e+09</td>\n",
       "      <td>4.054739e+09</td>\n",
       "      <td>21.504577</td>\n",
       "      <td>22.123152</td>\n",
       "      <td>-0.170799</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.179518</td>\n",
       "      <td>0.053739</td>\n",
       "      <td>1</td>\n",
       "      <td>0.067405</td>\n",
       "      <td>0.067405</td>\n",
       "      <td>7.076385e+08</td>\n",
       "      <td>23.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-04-30</td>\n",
       "      <td>15.99</td>\n",
       "      <td>37</td>\n",
       "      <td>21.0</td>\n",
       "      <td>2.320765e+09</td>\n",
       "      <td>4.307992e+09</td>\n",
       "      <td>21.565163</td>\n",
       "      <td>22.183738</td>\n",
       "      <td>0.062458</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>0.053739</td>\n",
       "      <td>-0.095648</td>\n",
       "      <td>1</td>\n",
       "      <td>0.063443</td>\n",
       "      <td>0.063443</td>\n",
       "      <td>5.862432e+08</td>\n",
       "      <td>44.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-05-31</td>\n",
       "      <td>14.60</td>\n",
       "      <td>38</td>\n",
       "      <td>21.0</td>\n",
       "      <td>2.119022e+09</td>\n",
       "      <td>3.933501e+09</td>\n",
       "      <td>21.474221</td>\n",
       "      <td>22.092796</td>\n",
       "      <td>-0.086929</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.095648</td>\n",
       "      <td>-0.088171</td>\n",
       "      <td>1</td>\n",
       "      <td>0.069483</td>\n",
       "      <td>0.069483</td>\n",
       "      <td>6.211901e+08</td>\n",
       "      <td>65.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-06-30</td>\n",
       "      <td>13.44</td>\n",
       "      <td>39</td>\n",
       "      <td>22.0</td>\n",
       "      <td>2.407403e+09</td>\n",
       "      <td>3.620977e+09</td>\n",
       "      <td>21.601814</td>\n",
       "      <td>22.010010</td>\n",
       "      <td>-0.079452</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.088171</td>\n",
       "      <td>-0.056046</td>\n",
       "      <td>1</td>\n",
       "      <td>0.075480</td>\n",
       "      <td>0.075480</td>\n",
       "      <td>4.647960e+08</td>\n",
       "      <td>87.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-07-31</td>\n",
       "      <td>8.00</td>\n",
       "      <td>40</td>\n",
       "      <td>18.0</td>\n",
       "      <td>2.292765e+09</td>\n",
       "      <td>3.448549e+09</td>\n",
       "      <td>21.553024</td>\n",
       "      <td>21.961219</td>\n",
       "      <td>-0.047327</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.056046</td>\n",
       "      <td>0.553781</td>\n",
       "      <td>1</td>\n",
       "      <td>0.079254</td>\n",
       "      <td>0.079254</td>\n",
       "      <td>3.490603e+08</td>\n",
       "      <td>105.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436789</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-08-31</td>\n",
       "      <td>13.56</td>\n",
       "      <td>24</td>\n",
       "      <td>23.0</td>\n",
       "      <td>7.955351e+09</td>\n",
       "      <td>1.054667e+10</td>\n",
       "      <td>22.797111</td>\n",
       "      <td>23.079076</td>\n",
       "      <td>-0.025862</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027103</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054878</td>\n",
       "      <td>0.036802</td>\n",
       "      <td>3.756695e+09</td>\n",
       "      <td>222.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436790</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-09-30</td>\n",
       "      <td>14.54</td>\n",
       "      <td>25</td>\n",
       "      <td>20.0</td>\n",
       "      <td>8.530295e+09</td>\n",
       "      <td>1.130889e+10</td>\n",
       "      <td>22.866890</td>\n",
       "      <td>23.148855</td>\n",
       "      <td>0.072271</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>1</td>\n",
       "      <td>0.051179</td>\n",
       "      <td>0.034322</td>\n",
       "      <td>3.756347e+09</td>\n",
       "      <td>242.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436791</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>13.85</td>\n",
       "      <td>26</td>\n",
       "      <td>17.0</td>\n",
       "      <td>8.125488e+09</td>\n",
       "      <td>1.077222e+10</td>\n",
       "      <td>22.818272</td>\n",
       "      <td>23.100237</td>\n",
       "      <td>-0.047455</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>1</td>\n",
       "      <td>0.058164</td>\n",
       "      <td>0.050524</td>\n",
       "      <td>3.736221e+09</td>\n",
       "      <td>243.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436792</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-11-30</td>\n",
       "      <td>13.48</td>\n",
       "      <td>27</td>\n",
       "      <td>22.0</td>\n",
       "      <td>7.908417e+09</td>\n",
       "      <td>1.048444e+10</td>\n",
       "      <td>22.791193</td>\n",
       "      <td>23.073159</td>\n",
       "      <td>-0.026715</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>1</td>\n",
       "      <td>0.059760</td>\n",
       "      <td>0.051910</td>\n",
       "      <td>3.908821e+09</td>\n",
       "      <td>243.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436793</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-12-31</td>\n",
       "      <td>14.89</td>\n",
       "      <td>28</td>\n",
       "      <td>21.0</td>\n",
       "      <td>8.735632e+09</td>\n",
       "      <td>1.158111e+10</td>\n",
       "      <td>22.890676</td>\n",
       "      <td>23.172641</td>\n",
       "      <td>0.104599</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054101</td>\n",
       "      <td>0.046995</td>\n",
       "      <td>3.845193e+09</td>\n",
       "      <td>242.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>436794 rows × 18 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Stkcd      month  price  Rank  Freq  floatingvalue    totalvalue  \\\n",
       "0       000001 1994-03-31  15.05    36  23.0   2.184334e+09  4.054739e+09   \n",
       "1       000001 1994-04-30  15.99    37  21.0   2.320765e+09  4.307992e+09   \n",
       "2       000001 1994-05-31  14.60    38  21.0   2.119022e+09  3.933501e+09   \n",
       "3       000001 1994-06-30  13.44    39  22.0   2.407403e+09  3.620977e+09   \n",
       "4       000001 1994-07-31   8.00    40  18.0   2.292765e+09  3.448549e+09   \n",
       "...        ...        ...    ...   ...   ...            ...           ...   \n",
       "436789  605599 2023-08-31  13.56    24  23.0   7.955351e+09  1.054667e+10   \n",
       "436790  605599 2023-09-30  14.54    25  20.0   8.530295e+09  1.130889e+10   \n",
       "436791  605599 2023-10-31  13.85    26  17.0   8.125488e+09  1.077222e+10   \n",
       "436792  605599 2023-11-30  13.48    27  22.0   7.908417e+09  1.048444e+10   \n",
       "436793  605599 2023-12-31  14.89    28  21.0   8.735632e+09  1.158111e+10   \n",
       "\n",
       "            sizef      sizet    Return   rfmonth       ret  next_ret  w  \\\n",
       "0       21.504577  22.123152 -0.170799  0.008719 -0.179518  0.053739  1   \n",
       "1       21.565163  22.183738  0.062458  0.008719  0.053739 -0.095648  1   \n",
       "2       21.474221  22.092796 -0.086929  0.008719 -0.095648 -0.088171  1   \n",
       "3       21.601814  22.010010 -0.079452  0.008719 -0.088171 -0.056046  1   \n",
       "4       21.553024  21.961219 -0.047327  0.008719 -0.056046  0.553781  1   \n",
       "...           ...        ...       ...       ...       ...       ... ..   \n",
       "436789  22.797111  23.079076 -0.025862  0.001241 -0.027103  0.071030  1   \n",
       "436790  22.866890  23.148855  0.072271  0.001241  0.071030 -0.048696  1   \n",
       "436791  22.818272  23.100237 -0.047455  0.001241 -0.048696 -0.027956  1   \n",
       "436792  22.791193  23.073159 -0.026715  0.001241 -0.027956  0.103358  1   \n",
       "436793  22.890676  23.172641  0.104599  0.001241  0.103358       NaN  1   \n",
       "\n",
       "              ep  ep_recent  fenweishu_guimo   N12m  \n",
       "0       0.067405   0.067405     7.076385e+08   23.0  \n",
       "1       0.063443   0.063443     5.862432e+08   44.0  \n",
       "2       0.069483   0.069483     6.211901e+08   65.0  \n",
       "3       0.075480   0.075480     4.647960e+08   87.0  \n",
       "4       0.079254   0.079254     3.490603e+08  105.0  \n",
       "...          ...        ...              ...    ...  \n",
       "436789  0.054878   0.036802     3.756695e+09  222.0  \n",
       "436790  0.051179   0.034322     3.756347e+09  242.0  \n",
       "436791  0.058164   0.050524     3.736221e+09  243.0  \n",
       "436792  0.059760   0.051910     3.908821e+09  243.0  \n",
       "436793  0.054101   0.046995     3.845193e+09  242.0  \n",
       "\n",
       "[436794 rows x 18 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cross_new = pd.merge(cross_new, freq_sums, on=['Stkcd', 'month'], how='left')\n",
    "cross_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Stkcd</th>\n",
       "      <th>month</th>\n",
       "      <th>price</th>\n",
       "      <th>Rank</th>\n",
       "      <th>Freq</th>\n",
       "      <th>floatingvalue</th>\n",
       "      <th>totalvalue</th>\n",
       "      <th>sizef</th>\n",
       "      <th>sizet</th>\n",
       "      <th>Return</th>\n",
       "      <th>rfmonth</th>\n",
       "      <th>ret</th>\n",
       "      <th>next_ret</th>\n",
       "      <th>w</th>\n",
       "      <th>ep</th>\n",
       "      <th>ep_recent</th>\n",
       "      <th>fenweishu_guimo</th>\n",
       "      <th>N12m</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-08-31</td>\n",
       "      <td>12.50</td>\n",
       "      <td>41</td>\n",
       "      <td>23.0</td>\n",
       "      <td>3.582445e+09</td>\n",
       "      <td>5.388358e+09</td>\n",
       "      <td>21.999311</td>\n",
       "      <td>22.407507</td>\n",
       "      <td>0.562500</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>0.553781</td>\n",
       "      <td>0.143281</td>\n",
       "      <td>1</td>\n",
       "      <td>0.050723</td>\n",
       "      <td>0.050723</td>\n",
       "      <td>7.468675e+08</td>\n",
       "      <td>128.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-09-30</td>\n",
       "      <td>14.40</td>\n",
       "      <td>42</td>\n",
       "      <td>22.0</td>\n",
       "      <td>4.282152e+09</td>\n",
       "      <td>6.207388e+09</td>\n",
       "      <td>22.177721</td>\n",
       "      <td>22.549006</td>\n",
       "      <td>0.152000</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>0.143281</td>\n",
       "      <td>-0.230941</td>\n",
       "      <td>1</td>\n",
       "      <td>0.044030</td>\n",
       "      <td>0.044030</td>\n",
       "      <td>7.914780e+08</td>\n",
       "      <td>150.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-10-31</td>\n",
       "      <td>11.20</td>\n",
       "      <td>43</td>\n",
       "      <td>19.0</td>\n",
       "      <td>3.330562e+09</td>\n",
       "      <td>4.827969e+09</td>\n",
       "      <td>21.926407</td>\n",
       "      <td>22.297692</td>\n",
       "      <td>-0.222222</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.230941</td>\n",
       "      <td>-0.008719</td>\n",
       "      <td>1</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>6.258511e+08</td>\n",
       "      <td>169.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-11-30</td>\n",
       "      <td>11.20</td>\n",
       "      <td>44</td>\n",
       "      <td>22.0</td>\n",
       "      <td>3.330562e+09</td>\n",
       "      <td>4.827969e+09</td>\n",
       "      <td>21.926407</td>\n",
       "      <td>22.297692</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.008719</td>\n",
       "      <td>-0.073005</td>\n",
       "      <td>1</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>6.042122e+08</td>\n",
       "      <td>191.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-12-31</td>\n",
       "      <td>10.48</td>\n",
       "      <td>45</td>\n",
       "      <td>22.0</td>\n",
       "      <td>3.116455e+09</td>\n",
       "      <td>4.517599e+09</td>\n",
       "      <td>21.859962</td>\n",
       "      <td>22.231247</td>\n",
       "      <td>-0.064286</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.073005</td>\n",
       "      <td>-0.002994</td>\n",
       "      <td>1</td>\n",
       "      <td>0.060499</td>\n",
       "      <td>0.060499</td>\n",
       "      <td>5.695092e+08</td>\n",
       "      <td>213.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436789</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-08-31</td>\n",
       "      <td>13.56</td>\n",
       "      <td>24</td>\n",
       "      <td>23.0</td>\n",
       "      <td>7.955351e+09</td>\n",
       "      <td>1.054667e+10</td>\n",
       "      <td>22.797111</td>\n",
       "      <td>23.079076</td>\n",
       "      <td>-0.025862</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027103</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054878</td>\n",
       "      <td>0.036802</td>\n",
       "      <td>3.756695e+09</td>\n",
       "      <td>222.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436790</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-09-30</td>\n",
       "      <td>14.54</td>\n",
       "      <td>25</td>\n",
       "      <td>20.0</td>\n",
       "      <td>8.530295e+09</td>\n",
       "      <td>1.130889e+10</td>\n",
       "      <td>22.866890</td>\n",
       "      <td>23.148855</td>\n",
       "      <td>0.072271</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>1</td>\n",
       "      <td>0.051179</td>\n",
       "      <td>0.034322</td>\n",
       "      <td>3.756347e+09</td>\n",
       "      <td>242.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436791</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>13.85</td>\n",
       "      <td>26</td>\n",
       "      <td>17.0</td>\n",
       "      <td>8.125488e+09</td>\n",
       "      <td>1.077222e+10</td>\n",
       "      <td>22.818272</td>\n",
       "      <td>23.100237</td>\n",
       "      <td>-0.047455</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>1</td>\n",
       "      <td>0.058164</td>\n",
       "      <td>0.050524</td>\n",
       "      <td>3.736221e+09</td>\n",
       "      <td>243.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436792</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-11-30</td>\n",
       "      <td>13.48</td>\n",
       "      <td>27</td>\n",
       "      <td>22.0</td>\n",
       "      <td>7.908417e+09</td>\n",
       "      <td>1.048444e+10</td>\n",
       "      <td>22.791193</td>\n",
       "      <td>23.073159</td>\n",
       "      <td>-0.026715</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>1</td>\n",
       "      <td>0.059760</td>\n",
       "      <td>0.051910</td>\n",
       "      <td>3.908821e+09</td>\n",
       "      <td>243.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436793</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-12-31</td>\n",
       "      <td>14.89</td>\n",
       "      <td>28</td>\n",
       "      <td>21.0</td>\n",
       "      <td>8.735632e+09</td>\n",
       "      <td>1.158111e+10</td>\n",
       "      <td>22.890676</td>\n",
       "      <td>23.172641</td>\n",
       "      <td>0.104599</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054101</td>\n",
       "      <td>0.046995</td>\n",
       "      <td>3.845193e+09</td>\n",
       "      <td>242.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>415424 rows × 18 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Stkcd      month  price  Rank  Freq  floatingvalue    totalvalue  \\\n",
       "5       000001 1994-08-31  12.50    41  23.0   3.582445e+09  5.388358e+09   \n",
       "6       000001 1994-09-30  14.40    42  22.0   4.282152e+09  6.207388e+09   \n",
       "7       000001 1994-10-31  11.20    43  19.0   3.330562e+09  4.827969e+09   \n",
       "8       000001 1994-11-30  11.20    44  22.0   3.330562e+09  4.827969e+09   \n",
       "9       000001 1994-12-31  10.48    45  22.0   3.116455e+09  4.517599e+09   \n",
       "...        ...        ...    ...   ...   ...            ...           ...   \n",
       "436789  605599 2023-08-31  13.56    24  23.0   7.955351e+09  1.054667e+10   \n",
       "436790  605599 2023-09-30  14.54    25  20.0   8.530295e+09  1.130889e+10   \n",
       "436791  605599 2023-10-31  13.85    26  17.0   8.125488e+09  1.077222e+10   \n",
       "436792  605599 2023-11-30  13.48    27  22.0   7.908417e+09  1.048444e+10   \n",
       "436793  605599 2023-12-31  14.89    28  21.0   8.735632e+09  1.158111e+10   \n",
       "\n",
       "            sizef      sizet    Return   rfmonth       ret  next_ret  w  \\\n",
       "5       21.999311  22.407507  0.562500  0.008719  0.553781  0.143281  1   \n",
       "6       22.177721  22.549006  0.152000  0.008719  0.143281 -0.230941  1   \n",
       "7       21.926407  22.297692 -0.222222  0.008719 -0.230941 -0.008719  1   \n",
       "8       21.926407  22.297692  0.000000  0.008719 -0.008719 -0.073005  1   \n",
       "9       21.859962  22.231247 -0.064286  0.008719 -0.073005 -0.002994  1   \n",
       "...           ...        ...       ...       ...       ...       ... ..   \n",
       "436789  22.797111  23.079076 -0.025862  0.001241 -0.027103  0.071030  1   \n",
       "436790  22.866890  23.148855  0.072271  0.001241  0.071030 -0.048696  1   \n",
       "436791  22.818272  23.100237 -0.047455  0.001241 -0.048696 -0.027956  1   \n",
       "436792  22.791193  23.073159 -0.026715  0.001241 -0.027956  0.103358  1   \n",
       "436793  22.890676  23.172641  0.104599  0.001241  0.103358       NaN  1   \n",
       "\n",
       "              ep  ep_recent  fenweishu_guimo   N12m  \n",
       "5       0.050723   0.050723     7.468675e+08  128.0  \n",
       "6       0.044030   0.044030     7.914780e+08  150.0  \n",
       "7       0.056610   0.056610     6.258511e+08  169.0  \n",
       "8       0.056610   0.056610     6.042122e+08  191.0  \n",
       "9       0.060499   0.060499     5.695092e+08  213.0  \n",
       "...          ...        ...              ...    ...  \n",
       "436789  0.054878   0.036802     3.756695e+09  222.0  \n",
       "436790  0.051179   0.034322     3.756347e+09  242.0  \n",
       "436791  0.058164   0.050524     3.736221e+09  243.0  \n",
       "436792  0.059760   0.051910     3.908821e+09  243.0  \n",
       "436793  0.054101   0.046995     3.845193e+09  242.0  \n",
       "\n",
       "[415424 rows x 18 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# ep是完整的\n",
    "cross_new = cross_new[(cross_new['Freq'] >= 7) & (cross_new['N12m'] > 120) & (cross_new['Rank'] > 6)]\n",
    "cross_new = cross_new.dropna(subset=['ep'])\n",
    "cross_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 规模价值分组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>guimo</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>month</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1991-06-30</th>\n",
       "      <td>9.808000e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-07-31</th>\n",
       "      <td>1.084536e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-08-31</th>\n",
       "      <td>6.632051e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-09-30</th>\n",
       "      <td>6.313829e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-10-31</th>\n",
       "      <td>7.644302e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-08-31</th>\n",
       "      <td>8.828683e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-09-30</th>\n",
       "      <td>8.763249e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-10-31</th>\n",
       "      <td>8.508268e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-11-30</th>\n",
       "      <td>8.774732e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-12-31</th>\n",
       "      <td>8.513869e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>391 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                   guimo\n",
       "month                   \n",
       "1991-06-30  9.808000e+08\n",
       "1991-07-31  1.084536e+08\n",
       "1991-08-31  6.632051e+08\n",
       "1991-09-30  6.313829e+08\n",
       "1991-10-31  7.644302e+08\n",
       "...                  ...\n",
       "2023-08-31  8.828683e+09\n",
       "2023-09-30  8.763249e+09\n",
       "2023-10-31  8.508268e+09\n",
       "2023-11-30  8.774732e+09\n",
       "2023-12-31  8.513869e+09\n",
       "\n",
       "[391 rows x 1 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guimo = cross_new.groupby(['month'])['totalvalue'].quantile(0.5).to_frame()\n",
    "guimo.columns = ['guimo']\n",
    "guimo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>jiazhi_30</th>\n",
       "      <th>jiazhi_70</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>month</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1991-06-30</th>\n",
       "      <td>0.023583</td>\n",
       "      <td>0.023583</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-07-31</th>\n",
       "      <td>0.007533</td>\n",
       "      <td>0.015879</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-08-31</th>\n",
       "      <td>0.002556</td>\n",
       "      <td>0.009436</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-09-30</th>\n",
       "      <td>0.002698</td>\n",
       "      <td>0.009566</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991-10-31</th>\n",
       "      <td>0.002390</td>\n",
       "      <td>0.008038</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-08-31</th>\n",
       "      <td>0.008239</td>\n",
       "      <td>0.042809</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-09-30</th>\n",
       "      <td>0.008598</td>\n",
       "      <td>0.042788</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-10-31</th>\n",
       "      <td>0.007530</td>\n",
       "      <td>0.043047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-11-30</th>\n",
       "      <td>0.006710</td>\n",
       "      <td>0.042006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-12-31</th>\n",
       "      <td>0.007075</td>\n",
       "      <td>0.042690</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>391 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            jiazhi_30  jiazhi_70\n",
       "month                           \n",
       "1991-06-30   0.023583   0.023583\n",
       "1991-07-31   0.007533   0.015879\n",
       "1991-08-31   0.002556   0.009436\n",
       "1991-09-30   0.002698   0.009566\n",
       "1991-10-31   0.002390   0.008038\n",
       "...               ...        ...\n",
       "2023-08-31   0.008239   0.042809\n",
       "2023-09-30   0.008598   0.042788\n",
       "2023-10-31   0.007530   0.043047\n",
       "2023-11-30   0.006710   0.042006\n",
       "2023-12-31   0.007075   0.042690\n",
       "\n",
       "[391 rows x 2 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiazhi = cross_new.groupby(['month'])['ep'].quantile([0.3,0.7]).to_frame()\n",
    "jiazhi.reset_index(inplace=True)\n",
    "jiazhi = jiazhi.pivot_table(index='month',columns='level_1',values='ep')\n",
    "jiazhi.columns = ['jiazhi_30','jiazhi_70']\n",
    "jiazhi"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 合并数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Stkcd</th>\n",
       "      <th>month</th>\n",
       "      <th>price</th>\n",
       "      <th>Rank</th>\n",
       "      <th>Freq</th>\n",
       "      <th>floatingvalue</th>\n",
       "      <th>totalvalue</th>\n",
       "      <th>sizef</th>\n",
       "      <th>sizet</th>\n",
       "      <th>Return</th>\n",
       "      <th>rfmonth</th>\n",
       "      <th>ret</th>\n",
       "      <th>next_ret</th>\n",
       "      <th>w</th>\n",
       "      <th>ep</th>\n",
       "      <th>ep_recent</th>\n",
       "      <th>fenweishu_guimo</th>\n",
       "      <th>N12m</th>\n",
       "      <th>guimo</th>\n",
       "      <th>jiazhi_30</th>\n",
       "      <th>jiazhi_70</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-08-31</td>\n",
       "      <td>12.50</td>\n",
       "      <td>41</td>\n",
       "      <td>23.0</td>\n",
       "      <td>3.582445e+09</td>\n",
       "      <td>5.388358e+09</td>\n",
       "      <td>21.999311</td>\n",
       "      <td>22.407507</td>\n",
       "      <td>0.562500</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>0.553781</td>\n",
       "      <td>0.143281</td>\n",
       "      <td>1</td>\n",
       "      <td>0.050723</td>\n",
       "      <td>0.050723</td>\n",
       "      <td>7.468675e+08</td>\n",
       "      <td>128.0</td>\n",
       "      <td>1.362266e+09</td>\n",
       "      <td>0.012236</td>\n",
       "      <td>0.050723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-09-30</td>\n",
       "      <td>14.40</td>\n",
       "      <td>42</td>\n",
       "      <td>22.0</td>\n",
       "      <td>4.282152e+09</td>\n",
       "      <td>6.207388e+09</td>\n",
       "      <td>22.177721</td>\n",
       "      <td>22.549006</td>\n",
       "      <td>0.152000</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>0.143281</td>\n",
       "      <td>-0.230941</td>\n",
       "      <td>1</td>\n",
       "      <td>0.044030</td>\n",
       "      <td>0.044030</td>\n",
       "      <td>7.914780e+08</td>\n",
       "      <td>150.0</td>\n",
       "      <td>1.307250e+09</td>\n",
       "      <td>0.018198</td>\n",
       "      <td>0.060208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-10-31</td>\n",
       "      <td>11.20</td>\n",
       "      <td>43</td>\n",
       "      <td>19.0</td>\n",
       "      <td>3.330562e+09</td>\n",
       "      <td>4.827969e+09</td>\n",
       "      <td>21.926407</td>\n",
       "      <td>22.297692</td>\n",
       "      <td>-0.222222</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.230941</td>\n",
       "      <td>-0.008719</td>\n",
       "      <td>1</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>6.258511e+08</td>\n",
       "      <td>169.0</td>\n",
       "      <td>1.085000e+09</td>\n",
       "      <td>0.027239</td>\n",
       "      <td>0.079492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-11-30</td>\n",
       "      <td>11.20</td>\n",
       "      <td>44</td>\n",
       "      <td>22.0</td>\n",
       "      <td>3.330562e+09</td>\n",
       "      <td>4.827969e+09</td>\n",
       "      <td>21.926407</td>\n",
       "      <td>22.297692</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.008719</td>\n",
       "      <td>-0.073005</td>\n",
       "      <td>1</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>6.042122e+08</td>\n",
       "      <td>191.0</td>\n",
       "      <td>1.114750e+09</td>\n",
       "      <td>0.027193</td>\n",
       "      <td>0.079674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-12-31</td>\n",
       "      <td>10.48</td>\n",
       "      <td>45</td>\n",
       "      <td>22.0</td>\n",
       "      <td>3.116455e+09</td>\n",
       "      <td>4.517599e+09</td>\n",
       "      <td>21.859962</td>\n",
       "      <td>22.231247</td>\n",
       "      <td>-0.064286</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.073005</td>\n",
       "      <td>-0.002994</td>\n",
       "      <td>1</td>\n",
       "      <td>0.060499</td>\n",
       "      <td>0.060499</td>\n",
       "      <td>5.695092e+08</td>\n",
       "      <td>213.0</td>\n",
       "      <td>1.020912e+09</td>\n",
       "      <td>0.028909</td>\n",
       "      <td>0.083968</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415419</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-08-31</td>\n",
       "      <td>13.56</td>\n",
       "      <td>24</td>\n",
       "      <td>23.0</td>\n",
       "      <td>7.955351e+09</td>\n",
       "      <td>1.054667e+10</td>\n",
       "      <td>22.797111</td>\n",
       "      <td>23.079076</td>\n",
       "      <td>-0.025862</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027103</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054878</td>\n",
       "      <td>0.036802</td>\n",
       "      <td>3.756695e+09</td>\n",
       "      <td>222.0</td>\n",
       "      <td>8.828683e+09</td>\n",
       "      <td>0.008239</td>\n",
       "      <td>0.042809</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415420</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-09-30</td>\n",
       "      <td>14.54</td>\n",
       "      <td>25</td>\n",
       "      <td>20.0</td>\n",
       "      <td>8.530295e+09</td>\n",
       "      <td>1.130889e+10</td>\n",
       "      <td>22.866890</td>\n",
       "      <td>23.148855</td>\n",
       "      <td>0.072271</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>1</td>\n",
       "      <td>0.051179</td>\n",
       "      <td>0.034322</td>\n",
       "      <td>3.756347e+09</td>\n",
       "      <td>242.0</td>\n",
       "      <td>8.763249e+09</td>\n",
       "      <td>0.008598</td>\n",
       "      <td>0.042788</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415421</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>13.85</td>\n",
       "      <td>26</td>\n",
       "      <td>17.0</td>\n",
       "      <td>8.125488e+09</td>\n",
       "      <td>1.077222e+10</td>\n",
       "      <td>22.818272</td>\n",
       "      <td>23.100237</td>\n",
       "      <td>-0.047455</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>1</td>\n",
       "      <td>0.058164</td>\n",
       "      <td>0.050524</td>\n",
       "      <td>3.736221e+09</td>\n",
       "      <td>243.0</td>\n",
       "      <td>8.508268e+09</td>\n",
       "      <td>0.007530</td>\n",
       "      <td>0.043047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415422</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-11-30</td>\n",
       "      <td>13.48</td>\n",
       "      <td>27</td>\n",
       "      <td>22.0</td>\n",
       "      <td>7.908417e+09</td>\n",
       "      <td>1.048444e+10</td>\n",
       "      <td>22.791193</td>\n",
       "      <td>23.073159</td>\n",
       "      <td>-0.026715</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>1</td>\n",
       "      <td>0.059760</td>\n",
       "      <td>0.051910</td>\n",
       "      <td>3.908821e+09</td>\n",
       "      <td>243.0</td>\n",
       "      <td>8.774732e+09</td>\n",
       "      <td>0.006710</td>\n",
       "      <td>0.042006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415423</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-12-31</td>\n",
       "      <td>14.89</td>\n",
       "      <td>28</td>\n",
       "      <td>21.0</td>\n",
       "      <td>8.735632e+09</td>\n",
       "      <td>1.158111e+10</td>\n",
       "      <td>22.890676</td>\n",
       "      <td>23.172641</td>\n",
       "      <td>0.104599</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054101</td>\n",
       "      <td>0.046995</td>\n",
       "      <td>3.845193e+09</td>\n",
       "      <td>242.0</td>\n",
       "      <td>8.513869e+09</td>\n",
       "      <td>0.007075</td>\n",
       "      <td>0.042690</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>415424 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Stkcd      month  price  Rank  Freq  floatingvalue    totalvalue  \\\n",
       "0       000001 1994-08-31  12.50    41  23.0   3.582445e+09  5.388358e+09   \n",
       "1       000001 1994-09-30  14.40    42  22.0   4.282152e+09  6.207388e+09   \n",
       "2       000001 1994-10-31  11.20    43  19.0   3.330562e+09  4.827969e+09   \n",
       "3       000001 1994-11-30  11.20    44  22.0   3.330562e+09  4.827969e+09   \n",
       "4       000001 1994-12-31  10.48    45  22.0   3.116455e+09  4.517599e+09   \n",
       "...        ...        ...    ...   ...   ...            ...           ...   \n",
       "415419  605599 2023-08-31  13.56    24  23.0   7.955351e+09  1.054667e+10   \n",
       "415420  605599 2023-09-30  14.54    25  20.0   8.530295e+09  1.130889e+10   \n",
       "415421  605599 2023-10-31  13.85    26  17.0   8.125488e+09  1.077222e+10   \n",
       "415422  605599 2023-11-30  13.48    27  22.0   7.908417e+09  1.048444e+10   \n",
       "415423  605599 2023-12-31  14.89    28  21.0   8.735632e+09  1.158111e+10   \n",
       "\n",
       "            sizef      sizet    Return   rfmonth       ret  next_ret  w  \\\n",
       "0       21.999311  22.407507  0.562500  0.008719  0.553781  0.143281  1   \n",
       "1       22.177721  22.549006  0.152000  0.008719  0.143281 -0.230941  1   \n",
       "2       21.926407  22.297692 -0.222222  0.008719 -0.230941 -0.008719  1   \n",
       "3       21.926407  22.297692  0.000000  0.008719 -0.008719 -0.073005  1   \n",
       "4       21.859962  22.231247 -0.064286  0.008719 -0.073005 -0.002994  1   \n",
       "...           ...        ...       ...       ...       ...       ... ..   \n",
       "415419  22.797111  23.079076 -0.025862  0.001241 -0.027103  0.071030  1   \n",
       "415420  22.866890  23.148855  0.072271  0.001241  0.071030 -0.048696  1   \n",
       "415421  22.818272  23.100237 -0.047455  0.001241 -0.048696 -0.027956  1   \n",
       "415422  22.791193  23.073159 -0.026715  0.001241 -0.027956  0.103358  1   \n",
       "415423  22.890676  23.172641  0.104599  0.001241  0.103358       NaN  1   \n",
       "\n",
       "              ep  ep_recent  fenweishu_guimo   N12m         guimo  jiazhi_30  \\\n",
       "0       0.050723   0.050723     7.468675e+08  128.0  1.362266e+09   0.012236   \n",
       "1       0.044030   0.044030     7.914780e+08  150.0  1.307250e+09   0.018198   \n",
       "2       0.056610   0.056610     6.258511e+08  169.0  1.085000e+09   0.027239   \n",
       "3       0.056610   0.056610     6.042122e+08  191.0  1.114750e+09   0.027193   \n",
       "4       0.060499   0.060499     5.695092e+08  213.0  1.020912e+09   0.028909   \n",
       "...          ...        ...              ...    ...           ...        ...   \n",
       "415419  0.054878   0.036802     3.756695e+09  222.0  8.828683e+09   0.008239   \n",
       "415420  0.051179   0.034322     3.756347e+09  242.0  8.763249e+09   0.008598   \n",
       "415421  0.058164   0.050524     3.736221e+09  243.0  8.508268e+09   0.007530   \n",
       "415422  0.059760   0.051910     3.908821e+09  243.0  8.774732e+09   0.006710   \n",
       "415423  0.054101   0.046995     3.845193e+09  242.0  8.513869e+09   0.007075   \n",
       "\n",
       "        jiazhi_70  \n",
       "0        0.050723  \n",
       "1        0.060208  \n",
       "2        0.079492  \n",
       "3        0.079674  \n",
       "4        0.083968  \n",
       "...           ...  \n",
       "415419   0.042809  \n",
       "415420   0.042788  \n",
       "415421   0.043047  \n",
       "415422   0.042006  \n",
       "415423   0.042690  \n",
       "\n",
       "[415424 rows x 21 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cross_new = pd.merge(cross_new,guimo,on='month',how='left')\n",
    "cross_new = pd.merge(cross_new,jiazhi,on='month',how='left')\n",
    "cross_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\w'k'd'n\\AppData\\Local\\Temp\\ipykernel_45148\\2617799624.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  cross_new['size'] = np.where(cross_new['totalvalue'] > cross_new['guimo'],'B','S')\n",
      "C:\\Users\\w'k'd'n\\AppData\\Local\\Temp\\ipykernel_45148\\2617799624.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  cross_new['value'] = np.where(cross_new['ep'] > cross_new['jiazhi_70'],'V',\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Stkcd</th>\n",
       "      <th>month</th>\n",
       "      <th>price</th>\n",
       "      <th>Rank</th>\n",
       "      <th>Freq</th>\n",
       "      <th>floatingvalue</th>\n",
       "      <th>totalvalue</th>\n",
       "      <th>sizef</th>\n",
       "      <th>sizet</th>\n",
       "      <th>Return</th>\n",
       "      <th>rfmonth</th>\n",
       "      <th>ret</th>\n",
       "      <th>next_ret</th>\n",
       "      <th>w</th>\n",
       "      <th>ep</th>\n",
       "      <th>ep_recent</th>\n",
       "      <th>fenweishu_guimo</th>\n",
       "      <th>N12m</th>\n",
       "      <th>guimo</th>\n",
       "      <th>jiazhi_30</th>\n",
       "      <th>jiazhi_70</th>\n",
       "      <th>size</th>\n",
       "      <th>value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-08-31</td>\n",
       "      <td>12.50</td>\n",
       "      <td>41</td>\n",
       "      <td>23.0</td>\n",
       "      <td>3.582445e+09</td>\n",
       "      <td>5.388358e+09</td>\n",
       "      <td>21.999311</td>\n",
       "      <td>22.407507</td>\n",
       "      <td>0.562500</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>0.553781</td>\n",
       "      <td>0.143281</td>\n",
       "      <td>1</td>\n",
       "      <td>0.050723</td>\n",
       "      <td>0.050723</td>\n",
       "      <td>7.468675e+08</td>\n",
       "      <td>128.0</td>\n",
       "      <td>1.362266e+09</td>\n",
       "      <td>0.012236</td>\n",
       "      <td>0.050723</td>\n",
       "      <td>B</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-09-30</td>\n",
       "      <td>14.40</td>\n",
       "      <td>42</td>\n",
       "      <td>22.0</td>\n",
       "      <td>4.282152e+09</td>\n",
       "      <td>6.207388e+09</td>\n",
       "      <td>22.177721</td>\n",
       "      <td>22.549006</td>\n",
       "      <td>0.152000</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>0.143281</td>\n",
       "      <td>-0.230941</td>\n",
       "      <td>1</td>\n",
       "      <td>0.044030</td>\n",
       "      <td>0.044030</td>\n",
       "      <td>7.914780e+08</td>\n",
       "      <td>150.0</td>\n",
       "      <td>1.307250e+09</td>\n",
       "      <td>0.018198</td>\n",
       "      <td>0.060208</td>\n",
       "      <td>B</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-10-31</td>\n",
       "      <td>11.20</td>\n",
       "      <td>43</td>\n",
       "      <td>19.0</td>\n",
       "      <td>3.330562e+09</td>\n",
       "      <td>4.827969e+09</td>\n",
       "      <td>21.926407</td>\n",
       "      <td>22.297692</td>\n",
       "      <td>-0.222222</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.230941</td>\n",
       "      <td>-0.008719</td>\n",
       "      <td>1</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>6.258511e+08</td>\n",
       "      <td>169.0</td>\n",
       "      <td>1.085000e+09</td>\n",
       "      <td>0.027239</td>\n",
       "      <td>0.079492</td>\n",
       "      <td>B</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-11-30</td>\n",
       "      <td>11.20</td>\n",
       "      <td>44</td>\n",
       "      <td>22.0</td>\n",
       "      <td>3.330562e+09</td>\n",
       "      <td>4.827969e+09</td>\n",
       "      <td>21.926407</td>\n",
       "      <td>22.297692</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.008719</td>\n",
       "      <td>-0.073005</td>\n",
       "      <td>1</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>0.056610</td>\n",
       "      <td>6.042122e+08</td>\n",
       "      <td>191.0</td>\n",
       "      <td>1.114750e+09</td>\n",
       "      <td>0.027193</td>\n",
       "      <td>0.079674</td>\n",
       "      <td>B</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000001</td>\n",
       "      <td>1994-12-31</td>\n",
       "      <td>10.48</td>\n",
       "      <td>45</td>\n",
       "      <td>22.0</td>\n",
       "      <td>3.116455e+09</td>\n",
       "      <td>4.517599e+09</td>\n",
       "      <td>21.859962</td>\n",
       "      <td>22.231247</td>\n",
       "      <td>-0.064286</td>\n",
       "      <td>0.008719</td>\n",
       "      <td>-0.073005</td>\n",
       "      <td>-0.002994</td>\n",
       "      <td>1</td>\n",
       "      <td>0.060499</td>\n",
       "      <td>0.060499</td>\n",
       "      <td>5.695092e+08</td>\n",
       "      <td>213.0</td>\n",
       "      <td>1.020912e+09</td>\n",
       "      <td>0.028909</td>\n",
       "      <td>0.083968</td>\n",
       "      <td>B</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415418</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-07-31</td>\n",
       "      <td>13.92</td>\n",
       "      <td>23</td>\n",
       "      <td>21.0</td>\n",
       "      <td>8.166555e+09</td>\n",
       "      <td>1.082667e+10</td>\n",
       "      <td>22.823313</td>\n",
       "      <td>23.105278</td>\n",
       "      <td>0.053747</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.052506</td>\n",
       "      <td>-0.027103</td>\n",
       "      <td>1</td>\n",
       "      <td>0.041298</td>\n",
       "      <td>0.019832</td>\n",
       "      <td>3.901419e+09</td>\n",
       "      <td>199.0</td>\n",
       "      <td>9.315662e+09</td>\n",
       "      <td>0.008352</td>\n",
       "      <td>0.040397</td>\n",
       "      <td>B</td>\n",
       "      <td>V</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415419</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-08-31</td>\n",
       "      <td>13.56</td>\n",
       "      <td>24</td>\n",
       "      <td>23.0</td>\n",
       "      <td>7.955351e+09</td>\n",
       "      <td>1.054667e+10</td>\n",
       "      <td>22.797111</td>\n",
       "      <td>23.079076</td>\n",
       "      <td>-0.025862</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027103</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>1</td>\n",
       "      <td>0.054878</td>\n",
       "      <td>0.036802</td>\n",
       "      <td>3.756695e+09</td>\n",
       "      <td>222.0</td>\n",
       "      <td>8.828683e+09</td>\n",
       "      <td>0.008239</td>\n",
       "      <td>0.042809</td>\n",
       "      <td>B</td>\n",
       "      <td>V</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415420</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-09-30</td>\n",
       "      <td>14.54</td>\n",
       "      <td>25</td>\n",
       "      <td>20.0</td>\n",
       "      <td>8.530295e+09</td>\n",
       "      <td>1.130889e+10</td>\n",
       "      <td>22.866890</td>\n",
       "      <td>23.148855</td>\n",
       "      <td>0.072271</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>0.071030</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>1</td>\n",
       "      <td>0.051179</td>\n",
       "      <td>0.034322</td>\n",
       "      <td>3.756347e+09</td>\n",
       "      <td>242.0</td>\n",
       "      <td>8.763249e+09</td>\n",
       "      <td>0.008598</td>\n",
       "      <td>0.042788</td>\n",
       "      <td>B</td>\n",
       "      <td>V</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415421</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-10-31</td>\n",
       "      <td>13.85</td>\n",
       "      <td>26</td>\n",
       "      <td>17.0</td>\n",
       "      <td>8.125488e+09</td>\n",
       "      <td>1.077222e+10</td>\n",
       "      <td>22.818272</td>\n",
       "      <td>23.100237</td>\n",
       "      <td>-0.047455</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.048696</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>1</td>\n",
       "      <td>0.058164</td>\n",
       "      <td>0.050524</td>\n",
       "      <td>3.736221e+09</td>\n",
       "      <td>243.0</td>\n",
       "      <td>8.508268e+09</td>\n",
       "      <td>0.007530</td>\n",
       "      <td>0.043047</td>\n",
       "      <td>B</td>\n",
       "      <td>V</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415422</th>\n",
       "      <td>605599</td>\n",
       "      <td>2023-11-30</td>\n",
       "      <td>13.48</td>\n",
       "      <td>27</td>\n",
       "      <td>22.0</td>\n",
       "      <td>7.908417e+09</td>\n",
       "      <td>1.048444e+10</td>\n",
       "      <td>22.791193</td>\n",
       "      <td>23.073159</td>\n",
       "      <td>-0.026715</td>\n",
       "      <td>0.001241</td>\n",
       "      <td>-0.027956</td>\n",
       "      <td>0.103358</td>\n",
       "      <td>1</td>\n",
       "      <td>0.059760</td>\n",
       "      <td>0.051910</td>\n",
       "      <td>3.908821e+09</td>\n",
       "      <td>243.0</td>\n",
       "      <td>8.774732e+09</td>\n",
       "      <td>0.006710</td>\n",
       "      <td>0.042006</td>\n",
       "      <td>B</td>\n",
       "      <td>V</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>410887 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Stkcd      month  price  Rank  Freq  floatingvalue    totalvalue  \\\n",
       "0       000001 1994-08-31  12.50    41  23.0   3.582445e+09  5.388358e+09   \n",
       "1       000001 1994-09-30  14.40    42  22.0   4.282152e+09  6.207388e+09   \n",
       "2       000001 1994-10-31  11.20    43  19.0   3.330562e+09  4.827969e+09   \n",
       "3       000001 1994-11-30  11.20    44  22.0   3.330562e+09  4.827969e+09   \n",
       "4       000001 1994-12-31  10.48    45  22.0   3.116455e+09  4.517599e+09   \n",
       "...        ...        ...    ...   ...   ...            ...           ...   \n",
       "415418  605599 2023-07-31  13.92    23  21.0   8.166555e+09  1.082667e+10   \n",
       "415419  605599 2023-08-31  13.56    24  23.0   7.955351e+09  1.054667e+10   \n",
       "415420  605599 2023-09-30  14.54    25  20.0   8.530295e+09  1.130889e+10   \n",
       "415421  605599 2023-10-31  13.85    26  17.0   8.125488e+09  1.077222e+10   \n",
       "415422  605599 2023-11-30  13.48    27  22.0   7.908417e+09  1.048444e+10   \n",
       "\n",
       "            sizef      sizet    Return   rfmonth       ret  next_ret  w  \\\n",
       "0       21.999311  22.407507  0.562500  0.008719  0.553781  0.143281  1   \n",
       "1       22.177721  22.549006  0.152000  0.008719  0.143281 -0.230941  1   \n",
       "2       21.926407  22.297692 -0.222222  0.008719 -0.230941 -0.008719  1   \n",
       "3       21.926407  22.297692  0.000000  0.008719 -0.008719 -0.073005  1   \n",
       "4       21.859962  22.231247 -0.064286  0.008719 -0.073005 -0.002994  1   \n",
       "...           ...        ...       ...       ...       ...       ... ..   \n",
       "415418  22.823313  23.105278  0.053747  0.001241  0.052506 -0.027103  1   \n",
       "415419  22.797111  23.079076 -0.025862  0.001241 -0.027103  0.071030  1   \n",
       "415420  22.866890  23.148855  0.072271  0.001241  0.071030 -0.048696  1   \n",
       "415421  22.818272  23.100237 -0.047455  0.001241 -0.048696 -0.027956  1   \n",
       "415422  22.791193  23.073159 -0.026715  0.001241 -0.027956  0.103358  1   \n",
       "\n",
       "              ep  ep_recent  fenweishu_guimo   N12m         guimo  jiazhi_30  \\\n",
       "0       0.050723   0.050723     7.468675e+08  128.0  1.362266e+09   0.012236   \n",
       "1       0.044030   0.044030     7.914780e+08  150.0  1.307250e+09   0.018198   \n",
       "2       0.056610   0.056610     6.258511e+08  169.0  1.085000e+09   0.027239   \n",
       "3       0.056610   0.056610     6.042122e+08  191.0  1.114750e+09   0.027193   \n",
       "4       0.060499   0.060499     5.695092e+08  213.0  1.020912e+09   0.028909   \n",
       "...          ...        ...              ...    ...           ...        ...   \n",
       "415418  0.041298   0.019832     3.901419e+09  199.0  9.315662e+09   0.008352   \n",
       "415419  0.054878   0.036802     3.756695e+09  222.0  8.828683e+09   0.008239   \n",
       "415420  0.051179   0.034322     3.756347e+09  242.0  8.763249e+09   0.008598   \n",
       "415421  0.058164   0.050524     3.736221e+09  243.0  8.508268e+09   0.007530   \n",
       "415422  0.059760   0.051910     3.908821e+09  243.0  8.774732e+09   0.006710   \n",
       "\n",
       "        jiazhi_70 size value  \n",
       "0        0.050723    B     M  \n",
       "1        0.060208    B     M  \n",
       "2        0.079492    B     M  \n",
       "3        0.079674    B     M  \n",
       "4        0.083968    B     M  \n",
       "...           ...  ...   ...  \n",
       "415418   0.040397    B     V  \n",
       "415419   0.042809    B     V  \n",
       "415420   0.042788    B     V  \n",
       "415421   0.043047    B     V  \n",
       "415422   0.042006    B     V  \n",
       "\n",
       "[410887 rows x 23 columns]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "' \\nnote the totalvale > guimo will be big, else small\\nnote the ep > jiazhi_70 will be value, else > jiazhi_30 will be median, else growth\\n\\n# 计算每月的日回报率'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cross_new['size'] = np.where(cross_new['totalvalue'] > cross_new['guimo'],'B','S')\n",
    "cross_new['value'] = np.where(cross_new['ep'] > cross_new['jiazhi_70'],'V',\n",
    "                              np.where(cross_new['ep'] > cross_new['jiazhi_30'],'M','G'))\n",
    "cross_new = cross_new.dropna(subset=['next_ret','totalvalue'])\n",
    "cross_new\n",
    "''' \n",
    "note the totalvale > guimo will be big, else small\n",
    "note the ep > jiazhi_70 will be value, else > jiazhi_30 will be median, else growth\n",
    "\n",
    "# 计算每月的日回报率'''"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 计算交叉分组里的加权收益率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "SV = cross_new[(cross_new['size'] == 'S') & (cross_new['value'] == 'V')].groupby(['month']).apply(lambda x: np.average(x['next_ret'],weights=x['totalvalue']),include_groups=False).to_frame()\n",
    "SV.columns = ['SV']\n",
    "SM = cross_new[(cross_new['size'] == 'S') & (cross_new['value'] == 'M')].groupby(['month']).apply(lambda x: np.average(x['next_ret'],weights=x['totalvalue']),include_groups=False).to_frame()\n",
    "SM.columns = ['SM']\n",
    "SG = cross_new[(cross_new['size'] == 'S') & (cross_new['value'] == 'G')].groupby(['month']).apply(lambda x: np.average(x['next_ret'],weights=x['totalvalue']),include_groups=False).to_frame()\n",
    "SG.columns = ['SG']\n",
    "BV = cross_new[(cross_new['size'] == 'B') & (cross_new['value'] == 'V')].groupby(['month']).apply(lambda x: np.average(x['next_ret'],weights=x['totalvalue']),include_groups=False).to_frame()\n",
    "BV.columns = ['BV']\n",
    "BM = cross_new[(cross_new['size'] == 'B') & (cross_new['value'] == 'M')].groupby(['month']).apply(lambda x: np.average(x['next_ret'],weights=x['totalvalue']),include_groups=False).to_frame()\n",
    "BM.columns = ['BM']\n",
    "BG = cross_new[(cross_new['size'] == 'B') & (cross_new['value'] == 'G')].groupby(['month']).apply(lambda x: np.average(x['next_ret'],weights=x['totalvalue']),include_groups=False).to_frame()\n",
    "BG.columns = ['BG']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SV</th>\n",
       "      <th>SM</th>\n",
       "      <th>SG</th>\n",
       "      <th>BV</th>\n",
       "      <th>BM</th>\n",
       "      <th>BG</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>month</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-31</th>\n",
       "      <td>0.118153</td>\n",
       "      <td>0.124455</td>\n",
       "      <td>0.167598</td>\n",
       "      <td>0.108332</td>\n",
       "      <td>0.176749</td>\n",
       "      <td>0.170767</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-02-29</th>\n",
       "      <td>0.111271</td>\n",
       "      <td>0.126431</td>\n",
       "      <td>0.150399</td>\n",
       "      <td>0.064749</td>\n",
       "      <td>0.109924</td>\n",
       "      <td>0.160440</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-03-31</th>\n",
       "      <td>0.104495</td>\n",
       "      <td>0.075740</td>\n",
       "      <td>0.113793</td>\n",
       "      <td>0.033485</td>\n",
       "      <td>0.014677</td>\n",
       "      <td>0.014215</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-30</th>\n",
       "      <td>0.009517</td>\n",
       "      <td>0.019136</td>\n",
       "      <td>0.000081</td>\n",
       "      <td>0.033479</td>\n",
       "      <td>0.016515</td>\n",
       "      <td>0.014719</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-05-31</th>\n",
       "      <td>0.034380</td>\n",
       "      <td>0.027609</td>\n",
       "      <td>0.048614</td>\n",
       "      <td>0.032781</td>\n",
       "      <td>0.015170</td>\n",
       "      <td>-0.011740</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-08-31</th>\n",
       "      <td>-0.057468</td>\n",
       "      <td>-0.049622</td>\n",
       "      <td>-0.055596</td>\n",
       "      <td>-0.058074</td>\n",
       "      <td>-0.057212</td>\n",
       "      <td>-0.075582</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-09-30</th>\n",
       "      <td>0.001074</td>\n",
       "      <td>0.003107</td>\n",
       "      <td>0.001164</td>\n",
       "      <td>0.004296</td>\n",
       "      <td>-0.026152</td>\n",
       "      <td>-0.021628</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-10-31</th>\n",
       "      <td>-0.023966</td>\n",
       "      <td>-0.009946</td>\n",
       "      <td>0.002619</td>\n",
       "      <td>-0.042213</td>\n",
       "      <td>-0.025697</td>\n",
       "      <td>-0.000485</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-11-30</th>\n",
       "      <td>0.022993</td>\n",
       "      <td>0.046284</td>\n",
       "      <td>0.036355</td>\n",
       "      <td>-0.014139</td>\n",
       "      <td>-0.000032</td>\n",
       "      <td>-0.001483</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-12-31</th>\n",
       "      <td>-0.020503</td>\n",
       "      <td>-0.025093</td>\n",
       "      <td>-0.040714</td>\n",
       "      <td>-0.011144</td>\n",
       "      <td>-0.029112</td>\n",
       "      <td>-0.036169</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>288 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                  SV        SM        SG        BV        BM        BG\n",
       "month                                                                 \n",
       "2000-01-31  0.118153  0.124455  0.167598  0.108332  0.176749  0.170767\n",
       "2000-02-29  0.111271  0.126431  0.150399  0.064749  0.109924  0.160440\n",
       "2000-03-31  0.104495  0.075740  0.113793  0.033485  0.014677  0.014215\n",
       "2000-04-30  0.009517  0.019136  0.000081  0.033479  0.016515  0.014719\n",
       "2000-05-31  0.034380  0.027609  0.048614  0.032781  0.015170 -0.011740\n",
       "...              ...       ...       ...       ...       ...       ...\n",
       "2023-08-31 -0.057468 -0.049622 -0.055596 -0.058074 -0.057212 -0.075582\n",
       "2023-09-30  0.001074  0.003107  0.001164  0.004296 -0.026152 -0.021628\n",
       "2023-10-31 -0.023966 -0.009946  0.002619 -0.042213 -0.025697 -0.000485\n",
       "2023-11-30  0.022993  0.046284  0.036355 -0.014139 -0.000032 -0.001483\n",
       "2023-12-31 -0.020503 -0.025093 -0.040714 -0.011144 -0.029112 -0.036169\n",
       "\n",
       "[288 rows x 6 columns]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 改进后的代码\n",
    "def weighted_ret(group):\n",
    "    return np.average(group['next_ret'], weights=group['totalvalue'])\n",
    "\n",
    "def calc_portfolio_returns(data):\n",
    "    portfolios = {}\n",
    "    for size in ['S', 'B']:\n",
    "        for value in ['V', 'M', 'G']:\n",
    "            mask = (data['size'] == size) & (data['value'] == value)\n",
    "            port_name = f'{size}{value}'\n",
    "            portfolios[port_name] = (data[mask]\n",
    "                                   .groupby('month')\n",
    "                                   .apply(weighted_ret,include_groups=False)\n",
    "                                   .to_frame(name=port_name))\n",
    "    return pd.concat(portfolios.values(), axis=1)\n",
    "    \n",
    "six_portfolio = calc_portfolio_returns(cross_new)\n",
    "# index is month and plus one month\n",
    "six_portfolio.index = six_portfolio.index + MonthEnd(1)\n",
    "six_portfolio = six_portfolio['2000-01':]\n",
    "six_portfolio"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## size of the portfolio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SMB</th>\n",
       "      <th>HML</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>month</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-31</th>\n",
       "      <td>-0.015214</td>\n",
       "      <td>-0.055941</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-02-29</th>\n",
       "      <td>0.017663</td>\n",
       "      <td>-0.067409</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-03-31</th>\n",
       "      <td>0.077217</td>\n",
       "      <td>0.004986</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-04-30</th>\n",
       "      <td>-0.011993</td>\n",
       "      <td>0.014098</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-05-31</th>\n",
       "      <td>0.024797</td>\n",
       "      <td>0.015143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-08-31</th>\n",
       "      <td>0.009394</td>\n",
       "      <td>0.007818</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-09-30</th>\n",
       "      <td>0.016276</td>\n",
       "      <td>0.012916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-10-31</th>\n",
       "      <td>0.012367</td>\n",
       "      <td>-0.034156</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-11-30</th>\n",
       "      <td>0.040428</td>\n",
       "      <td>-0.013009</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-12-31</th>\n",
       "      <td>-0.003295</td>\n",
       "      <td>0.022618</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>288 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 SMB       HML\n",
       "month                         \n",
       "2000-01-31 -0.015214 -0.055941\n",
       "2000-02-29  0.017663 -0.067409\n",
       "2000-03-31  0.077217  0.004986\n",
       "2000-04-30 -0.011993  0.014098\n",
       "2000-05-31  0.024797  0.015143\n",
       "...              ...       ...\n",
       "2023-08-31  0.009394  0.007818\n",
       "2023-09-30  0.016276  0.012916\n",
       "2023-10-31  0.012367 -0.034156\n",
       "2023-11-30  0.040428 -0.013009\n",
       "2023-12-31 -0.003295  0.022618\n",
       "\n",
       "[288 rows x 2 columns]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def calc_factors(portfolios):\n",
    "    # SMB因子\n",
    "    smb = ((portfolios['SV'] + portfolios['SM'] + portfolios['SG'])/3 - \n",
    "           (portfolios['BV'] + portfolios['BM'] + portfolios['BG'])/3)\n",
    "    \n",
    "    # HML因子\n",
    "    hml = ((portfolios['SV'] + portfolios['BV'])/2 - \n",
    "           (portfolios['SG'] + portfolios['BG'])/2)\n",
    "    \n",
    "    return pd.DataFrame({\n",
    "        'SMB': smb,\n",
    "        'HML': hml\n",
    "    })\n",
    "\n",
    "factors = calc_factors(six_portfolio)\n",
    "factors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"721.645312pt\" height=\"363.718125pt\" viewBox=\"0 0 721.645312 363.718125\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2024-12-17T20:28:22.253879</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.8.4, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 363.718125 \n",
       "L 721.645312 363.718125 \n",
       "L 721.645312 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 44.845313 339.84 \n",
       "L 714.445312 339.84 \n",
       "L 714.445312 7.2 \n",
       "L 44.845313 7.2 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path id=\"m73b89f3902\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m73b89f3902\" x=\"73.191027\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 2000 -->\n",
       "      <g transform=\"translate(60.466027 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m73b89f3902\" x=\"175.005629\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 2004 -->\n",
       "      <g transform=\"translate(162.280629 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m73b89f3902\" x=\"276.820231\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 2008 -->\n",
       "      <g transform=\"translate(264.095231 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-38\" d=\"M 2034 2216 \n",
       "Q 1584 2216 1326 1975 \n",
       "Q 1069 1734 1069 1313 \n",
       "Q 1069 891 1326 650 \n",
       "Q 1584 409 2034 409 \n",
       "Q 2484 409 2743 651 \n",
       "Q 3003 894 3003 1313 \n",
       "Q 3003 1734 2745 1975 \n",
       "Q 2488 2216 2034 2216 \n",
       "z\n",
       "M 1403 2484 \n",
       "Q 997 2584 770 2862 \n",
       "Q 544 3141 544 3541 \n",
       "Q 544 4100 942 4425 \n",
       "Q 1341 4750 2034 4750 \n",
       "Q 2731 4750 3128 4425 \n",
       "Q 3525 4100 3525 3541 \n",
       "Q 3525 3141 3298 2862 \n",
       "Q 3072 2584 2669 2484 \n",
       "Q 3125 2378 3379 2068 \n",
       "Q 3634 1759 3634 1313 \n",
       "Q 3634 634 3220 271 \n",
       "Q 2806 -91 2034 -91 \n",
       "Q 1263 -91 848 271 \n",
       "Q 434 634 434 1313 \n",
       "Q 434 1759 690 2068 \n",
       "Q 947 2378 1403 2484 \n",
       "z\n",
       "M 1172 3481 \n",
       "Q 1172 3119 1398 2916 \n",
       "Q 1625 2713 2034 2713 \n",
       "Q 2441 2713 2670 2916 \n",
       "Q 2900 3119 2900 3481 \n",
       "Q 2900 3844 2670 4047 \n",
       "Q 2441 4250 2034 4250 \n",
       "Q 1625 4250 1398 4047 \n",
       "Q 1172 3844 1172 3481 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-38\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m73b89f3902\" x=\"378.634832\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 2012 -->\n",
       "      <g transform=\"translate(365.909832 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m73b89f3902\" x=\"480.449434\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 2016 -->\n",
       "      <g transform=\"translate(467.724434 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-36\" d=\"M 2113 2584 \n",
       "Q 1688 2584 1439 2293 \n",
       "Q 1191 2003 1191 1497 \n",
       "Q 1191 994 1439 701 \n",
       "Q 1688 409 2113 409 \n",
       "Q 2538 409 2786 701 \n",
       "Q 3034 994 3034 1497 \n",
       "Q 3034 2003 2786 2293 \n",
       "Q 2538 2584 2113 2584 \n",
       "z\n",
       "M 3366 4563 \n",
       "L 3366 3988 \n",
       "Q 3128 4100 2886 4159 \n",
       "Q 2644 4219 2406 4219 \n",
       "Q 1781 4219 1451 3797 \n",
       "Q 1122 3375 1075 2522 \n",
       "Q 1259 2794 1537 2939 \n",
       "Q 1816 3084 2150 3084 \n",
       "Q 2853 3084 3261 2657 \n",
       "Q 3669 2231 3669 1497 \n",
       "Q 3669 778 3244 343 \n",
       "Q 2819 -91 2113 -91 \n",
       "Q 1303 -91 875 529 \n",
       "Q 447 1150 447 2328 \n",
       "Q 447 3434 972 4092 \n",
       "Q 1497 4750 2381 4750 \n",
       "Q 2619 4750 2861 4703 \n",
       "Q 3103 4656 3366 4563 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m73b89f3902\" x=\"582.264036\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 2020 -->\n",
       "      <g transform=\"translate(569.539036 354.438437) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m73b89f3902\" x=\"684.078637\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 2024 -->\n",
       "      <g transform=\"translate(671.353637 354.438437) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <defs>\n",
       "       <path id=\"mc307c70bc3\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc307c70bc3\" x=\"44.845313\" y=\"299.711618\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- −0.15 -->\n",
       "      <g transform=\"translate(7.2 303.510837) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2212\" d=\"M 678 2272 \n",
       "L 4684 2272 \n",
       "L 4684 1741 \n",
       "L 678 1741 \n",
       "L 678 2272 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"83.789062\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"147.412109\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"179.199219\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"242.822266\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc307c70bc3\" x=\"44.845313\" y=\"254.631197\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- −0.10 -->\n",
       "      <g transform=\"translate(7.2 258.430416) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"83.789062\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"147.412109\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"179.199219\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"242.822266\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc307c70bc3\" x=\"44.845313\" y=\"209.550776\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- −0.05 -->\n",
       "      <g transform=\"translate(7.2 213.349994) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"83.789062\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"147.412109\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"179.199219\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"242.822266\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc307c70bc3\" x=\"44.845313\" y=\"164.470354\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 0.00 -->\n",
       "      <g transform=\"translate(15.579688 168.269573) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc307c70bc3\" x=\"44.845313\" y=\"119.389933\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 0.05 -->\n",
       "      <g transform=\"translate(15.579688 123.189152) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc307c70bc3\" x=\"44.845313\" y=\"74.309512\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 0.10 -->\n",
       "      <g transform=\"translate(15.579688 78.10873) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc307c70bc3\" x=\"44.845313\" y=\"29.22909\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 0.15 -->\n",
       "      <g transform=\"translate(15.579688 33.028309) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_15\">\n",
       "    <path d=\"M 75.281676 178.187081 \n",
       "L 77.302637 148.545273 \n",
       "L 79.462974 94.850573 \n",
       "L 81.553623 175.283029 \n",
       "L 83.71396 142.11315 \n",
       "L 85.804609 158.095838 \n",
       "L 87.964946 145.884794 \n",
       "L 90.125283 150.129387 \n",
       "L 92.215932 153.928687 \n",
       "L 94.376269 138.390867 \n",
       "L 96.466918 152.373124 \n",
       "L 98.627256 148.611318 \n",
       "L 100.787593 158.649919 \n",
       "L 102.738865 170.961423 \n",
       "L 104.899202 149.500241 \n",
       "L 106.989851 158.100524 \n",
       "L 109.150188 147.123936 \n",
       "L 111.240837 149.138921 \n",
       "L 113.401174 171.422081 \n",
       "L 115.561512 165.02068 \n",
       "L 117.652161 176.067496 \n",
       "L 119.812498 176.097162 \n",
       "L 121.903147 145.301693 \n",
       "L 124.063484 175.746691 \n",
       "L 126.223821 202.494017 \n",
       "L 128.175093 144.539186 \n",
       "L 130.335431 143.265257 \n",
       "L 132.42608 151.821064 \n",
       "L 134.586417 175.210573 \n",
       "L 136.677066 184.934967 \n",
       "L 138.837403 158.511703 \n",
       "L 140.99774 163.817452 \n",
       "L 143.088389 170.687586 \n",
       "L 145.248726 173.529112 \n",
       "L 147.339375 197.357032 \n",
       "L 149.499712 168.563139 \n",
       "L 151.660049 152.890625 \n",
       "L 153.611322 158.665141 \n",
       "L 155.771659 193.576064 \n",
       "L 157.862308 210.269797 \n",
       "L 160.022645 172.721883 \n",
       "L 162.113294 169.370275 \n",
       "L 164.273631 190.72506 \n",
       "L 166.433968 158.20598 \n",
       "L 168.524617 163.047155 \n",
       "L 170.684954 204.281394 \n",
       "L 172.775603 158.698411 \n",
       "L 174.935941 225.527558 \n",
       "L 177.096278 123.07619 \n",
       "L 179.117238 132.339579 \n",
       "L 181.277576 153.498144 \n",
       "L 183.368225 149.76413 \n",
       "L 185.528562 155.192106 \n",
       "L 187.619211 187.513637 \n",
       "L 189.779548 174.878092 \n",
       "L 191.939885 163.835978 \n",
       "L 194.030534 158.688955 \n",
       "L 196.190871 174.387758 \n",
       "L 198.28152 130.914261 \n",
       "L 200.441857 180.572039 \n",
       "L 202.602194 175.912359 \n",
       "L 204.553467 148.661751 \n",
       "L 206.713804 196.374573 \n",
       "L 208.804453 220.425696 \n",
       "L 210.96479 120.123232 \n",
       "L 213.055439 187.89629 \n",
       "L 215.215776 230.15014 \n",
       "L 217.376113 94.915652 \n",
       "L 219.466762 139.286415 \n",
       "L 221.627099 176.068187 \n",
       "L 223.717748 158.339881 \n",
       "L 225.878086 196.781025 \n",
       "L 228.038423 156.513099 \n",
       "L 229.989695 174.036053 \n",
       "L 232.150032 167.058697 \n",
       "L 234.240681 200.094832 \n",
       "L 236.401018 67.51171 \n",
       "L 238.491667 126.196347 \n",
       "L 240.652004 132.182162 \n",
       "L 242.812342 170.597542 \n",
       "L 244.902991 178.26625 \n",
       "L 247.063328 173.390648 \n",
       "L 249.153977 252.110068 \n",
       "L 251.314314 257.665075 \n",
       "L 253.474651 90.611895 \n",
       "L 255.425923 50.667455 \n",
       "L 257.586261 101.035517 \n",
       "L 259.67691 111.550276 \n",
       "L 261.837247 188.481166 \n",
       "L 263.927896 225.035683 \n",
       "L 266.088233 110.439721 \n",
       "L 268.24857 199.042834 \n",
       "L 270.339219 180.711241 \n",
       "L 272.499556 260.956262 \n",
       "L 274.590205 70.194376 \n",
       "L 276.750542 118.987602 \n",
       "L 278.910879 99.661008 \n",
       "L 280.93184 94.609333 \n",
       "L 283.092177 163.592115 \n",
       "L 285.182826 224.420995 \n",
       "L 287.343163 137.155556 \n",
       "L 289.433812 203.294951 \n",
       "L 291.594149 102.203176 \n",
       "L 293.754487 192.526592 \n",
       "L 295.845136 209.819215 \n",
       "L 298.005473 163.766768 \n",
       "L 300.096122 42.132076 \n",
       "L 302.256459 117.729777 \n",
       "L 304.416796 88.34195 \n",
       "L 306.368068 138.267867 \n",
       "L 308.528406 111.452269 \n",
       "L 310.619054 145.391394 \n",
       "L 312.779392 144.248821 \n",
       "L 314.870041 243.294063 \n",
       "L 317.030378 219.571373 \n",
       "L 319.190715 89.247558 \n",
       "L 321.281364 170.391761 \n",
       "L 325.53235 87.99607 \n",
       "L 327.692687 153.045087 \n",
       "L 329.853024 90.190378 \n",
       "L 331.804297 133.923063 \n",
       "L 333.964634 148.462276 \n",
       "L 336.055283 157.575 \n",
       "L 338.21562 165.701279 \n",
       "L 340.306269 170.89479 \n",
       "L 342.466606 122.888721 \n",
       "L 344.626943 118.498306 \n",
       "L 346.717592 181.508498 \n",
       "L 348.877929 191.729758 \n",
       "L 350.968578 124.467629 \n",
       "L 353.128916 181.213828 \n",
       "L 355.289253 165.110453 \n",
       "L 357.240525 128.743245 \n",
       "L 359.400862 160.323887 \n",
       "L 361.491511 170.300746 \n",
       "L 363.651848 173.374355 \n",
       "L 365.742497 159.918961 \n",
       "L 367.902834 150.476456 \n",
       "L 370.063172 155.903833 \n",
       "L 372.153821 179.963381 \n",
       "L 374.314158 164.608978 \n",
       "L 376.404807 163.818465 \n",
       "L 378.565144 214.592606 \n",
       "L 380.725481 177.036126 \n",
       "L 382.746442 117.577986 \n",
       "L 384.906779 166.743091 \n",
       "L 386.997428 140.913823 \n",
       "L 389.157765 159.186164 \n",
       "L 391.248414 181.905923 \n",
       "L 393.408751 199.569769 \n",
       "L 395.569088 119.994023 \n",
       "L 397.659737 183.535621 \n",
       "L 399.820074 152.871261 \n",
       "L 401.910723 201.526229 \n",
       "L 404.071061 158.838418 \n",
       "L 406.231398 146.085017 \n",
       "L 408.18267 139.207948 \n",
       "L 410.343007 151.176717 \n",
       "L 412.433656 171.746038 \n",
       "L 414.593993 116.454475 \n",
       "L 416.684642 185.342398 \n",
       "L 418.844979 139.151235 \n",
       "L 421.005317 125.820092 \n",
       "L 423.095966 170.96659 \n",
       "L 425.256303 150.802976 \n",
       "L 427.346952 133.516638 \n",
       "L 429.507289 148.979861 \n",
       "L 431.667626 137.819971 \n",
       "L 433.618898 123.045282 \n",
       "L 435.779236 144.85998 \n",
       "L 437.869884 177.833205 \n",
       "L 440.030222 153.656303 \n",
       "L 442.120871 143.97205 \n",
       "L 444.281208 151.395704 \n",
       "L 446.441545 141.823497 \n",
       "L 448.532194 116.260007 \n",
       "L 450.692531 158.349372 \n",
       "L 452.78318 182.80618 \n",
       "L 454.943517 324.72 \n",
       "L 457.103854 97.49081 \n",
       "L 459.055127 151.666394 \n",
       "L 461.215464 88.583816 \n",
       "L 463.306113 175.415408 \n",
       "L 465.46645 22.32 \n",
       "L 467.557099 181.050554 \n",
       "L 469.717436 197.939726 \n",
       "L 471.877773 158.264065 \n",
       "L 473.968422 134.87211 \n",
       "L 476.128759 96.587351 \n",
       "L 478.219408 93.390615 \n",
       "L 480.379746 128.205666 \n",
       "L 482.540083 201.83621 \n",
       "L 484.561043 166.283391 \n",
       "L 486.721381 114.646716 \n",
       "L 488.812029 145.701026 \n",
       "L 490.972367 170.424978 \n",
       "L 493.063016 124.503622 \n",
       "L 495.223353 176.126837 \n",
       "L 497.38369 155.148063 \n",
       "L 499.474339 154.1843 \n",
       "L 501.634676 155.292271 \n",
       "L 503.725325 180.865698 \n",
       "L 505.885662 163.211758 \n",
       "L 508.045999 194.517888 \n",
       "L 509.997272 152.780897 \n",
       "L 512.157609 172.803805 \n",
       "L 514.248258 193.91855 \n",
       "L 516.408595 207.593856 \n",
       "L 518.499244 166.944373 \n",
       "L 520.659581 177.728803 \n",
       "L 522.819918 166.670207 \n",
       "L 524.910567 158.852614 \n",
       "L 527.070904 203.615315 \n",
       "L 529.161553 196.564968 \n",
       "L 531.321891 181.839058 \n",
       "L 533.482228 210.00485 \n",
       "L 535.4335 162.351038 \n",
       "L 537.593837 130.479212 \n",
       "L 539.684486 177.639321 \n",
       "L 541.844823 187.306015 \n",
       "L 543.935472 195.705325 \n",
       "L 546.095809 165.965579 \n",
       "L 548.256147 185.976556 \n",
       "L 550.346796 188.687309 \n",
       "L 552.507133 173.410092 \n",
       "L 554.597782 115.343826 \n",
       "L 556.758119 172.298552 \n",
       "L 558.918456 207.141488 \n",
       "L 560.869728 113.694572 \n",
       "L 563.030066 128.886563 \n",
       "L 565.120714 186.218576 \n",
       "L 567.281052 151.425006 \n",
       "L 569.371701 192.853795 \n",
       "L 571.532038 192.004343 \n",
       "L 573.692375 178.707483 \n",
       "L 575.783024 155.816358 \n",
       "L 577.943361 187.298831 \n",
       "L 580.03401 173.871386 \n",
       "L 582.194347 153.109737 \n",
       "L 584.354684 165.343459 \n",
       "L 586.375645 164.559361 \n",
       "L 588.535982 137.269763 \n",
       "L 590.626631 203.028012 \n",
       "L 592.786968 154.245796 \n",
       "L 594.877617 190.933737 \n",
       "L 597.037954 165.037602 \n",
       "L 599.198292 143.119782 \n",
       "L 601.288941 186.151226 \n",
       "L 603.449278 182.344001 \n",
       "L 605.539927 178.164929 \n",
       "L 607.700264 246.610554 \n",
       "L 609.860601 252.653913 \n",
       "L 611.811873 118.456997 \n",
       "L 613.972211 111.984516 \n",
       "L 616.062859 190.522693 \n",
       "L 618.223197 159.997372 \n",
       "L 620.313846 149.855544 \n",
       "L 622.474183 120.996089 \n",
       "L 624.63452 129.796654 \n",
       "L 626.725169 172.242741 \n",
       "L 628.885506 196.492053 \n",
       "L 630.976155 65.108941 \n",
       "L 633.136492 127.331447 \n",
       "L 635.296829 168.633139 \n",
       "L 637.248102 134.5873 \n",
       "L 639.408439 127.43423 \n",
       "L 641.499088 238.509003 \n",
       "L 643.659425 111.112997 \n",
       "L 645.750074 184.419278 \n",
       "L 647.910411 101.90506 \n",
       "L 650.070748 173.364416 \n",
       "L 652.161397 187.386398 \n",
       "L 654.321734 101.15807 \n",
       "L 656.412383 156.642928 \n",
       "L 658.572721 184.248155 \n",
       "L 660.733058 153.391769 \n",
       "L 662.68433 127.809343 \n",
       "L 664.844667 181.458419 \n",
       "L 666.935316 187.003159 \n",
       "L 669.095653 131.50626 \n",
       "L 671.186302 149.053175 \n",
       "L 673.346639 182.480138 \n",
       "L 675.506977 156.000847 \n",
       "L 677.597626 149.795648 \n",
       "L 679.757963 153.319731 \n",
       "L 681.848612 128.019792 \n",
       "L 684.008949 167.441143 \n",
       "L 684.008949 167.441143 \n",
       "\" clip-path=\"url(#pbb4a528c0d)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 44.845313 339.84 \n",
       "L 44.845313 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 714.445312 339.84 \n",
       "L 714.445312 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 44.845312 339.84 \n",
       "L 714.445312 339.84 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 44.845312 7.2 \n",
       "L 714.445312 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 51.845313 29.878125 \n",
       "L 105.682813 29.878125 \n",
       "Q 107.682813 29.878125 107.682813 27.878125 \n",
       "L 107.682813 14.2 \n",
       "Q 107.682813 12.2 105.682813 12.2 \n",
       "L 51.845313 12.2 \n",
       "Q 49.845313 12.2 49.845313 14.2 \n",
       "L 49.845313 27.878125 \n",
       "Q 49.845313 29.878125 51.845313 29.878125 \n",
       "z\n",
       "\" style=\"fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_16\">\n",
       "     <path d=\"M 53.845313 20.298437 \n",
       "L 63.845313 20.298437 \n",
       "L 73.845313 20.298437 \n",
       "\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    </g>\n",
       "    <g id=\"text_15\">\n",
       "     <!-- SMB -->\n",
       "     <g transform=\"translate(81.845313 23.798437) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-53\" d=\"M 3425 4513 \n",
       "L 3425 3897 \n",
       "Q 3066 4069 2747 4153 \n",
       "Q 2428 4238 2131 4238 \n",
       "Q 1616 4238 1336 4038 \n",
       "Q 1056 3838 1056 3469 \n",
       "Q 1056 3159 1242 3001 \n",
       "Q 1428 2844 1947 2747 \n",
       "L 2328 2669 \n",
       "Q 3034 2534 3370 2195 \n",
       "Q 3706 1856 3706 1288 \n",
       "Q 3706 609 3251 259 \n",
       "Q 2797 -91 1919 -91 \n",
       "Q 1588 -91 1214 -16 \n",
       "Q 841 59 441 206 \n",
       "L 441 856 \n",
       "Q 825 641 1194 531 \n",
       "Q 1563 422 1919 422 \n",
       "Q 2459 422 2753 634 \n",
       "Q 3047 847 3047 1241 \n",
       "Q 3047 1584 2836 1778 \n",
       "Q 2625 1972 2144 2069 \n",
       "L 1759 2144 \n",
       "Q 1053 2284 737 2584 \n",
       "Q 422 2884 422 3419 \n",
       "Q 422 4038 858 4394 \n",
       "Q 1294 4750 2059 4750 \n",
       "Q 2388 4750 2728 4690 \n",
       "Q 3069 4631 3425 4513 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-4d\" d=\"M 628 4666 \n",
       "L 1569 4666 \n",
       "L 2759 1491 \n",
       "L 3956 4666 \n",
       "L 4897 4666 \n",
       "L 4897 0 \n",
       "L 4281 0 \n",
       "L 4281 4097 \n",
       "L 3078 897 \n",
       "L 2444 897 \n",
       "L 1241 4097 \n",
       "L 1241 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-42\" d=\"M 1259 2228 \n",
       "L 1259 519 \n",
       "L 2272 519 \n",
       "Q 2781 519 3026 730 \n",
       "Q 3272 941 3272 1375 \n",
       "Q 3272 1813 3026 2020 \n",
       "Q 2781 2228 2272 2228 \n",
       "L 1259 2228 \n",
       "z\n",
       "M 1259 4147 \n",
       "L 1259 2741 \n",
       "L 2194 2741 \n",
       "Q 2656 2741 2882 2914 \n",
       "Q 3109 3088 3109 3444 \n",
       "Q 3109 3797 2882 3972 \n",
       "Q 2656 4147 2194 4147 \n",
       "L 1259 4147 \n",
       "z\n",
       "M 628 4666 \n",
       "L 2241 4666 \n",
       "Q 2963 4666 3353 4366 \n",
       "Q 3744 4066 3744 3513 \n",
       "Q 3744 3084 3544 2831 \n",
       "Q 3344 2578 2956 2516 \n",
       "Q 3422 2416 3680 2098 \n",
       "Q 3938 1781 3938 1306 \n",
       "Q 3938 681 3513 340 \n",
       "Q 3088 0 2303 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-4d\" x=\"63.476562\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-42\" x=\"149.755859\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pbb4a528c0d\">\n",
       "   <rect x=\"44.845313\" y=\"7.2\" width=\"669.6\" height=\"332.64\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 1200x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(12,6))\n",
    "plt.plot(factors['SMB'], label='SMB')\n",
    "plt.legend(loc='upper left')\n",
    "plt.show();\n",
    "# plot smb values\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## value factor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"721.645312pt\" height=\"363.718125pt\" viewBox=\"0 0 721.645312 363.718125\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2024-12-17T20:28:58.476889</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.8.4, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 363.718125 \n",
       "L 721.645312 363.718125 \n",
       "L 721.645312 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 44.845313 339.84 \n",
       "L 714.445312 339.84 \n",
       "L 714.445312 7.2 \n",
       "L 44.845313 7.2 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path id=\"mdcd4386473\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdcd4386473\" x=\"73.191027\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 2000 -->\n",
       "      <g transform=\"translate(60.466027 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdcd4386473\" x=\"175.005629\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 2004 -->\n",
       "      <g transform=\"translate(162.280629 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdcd4386473\" x=\"276.820231\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 2008 -->\n",
       "      <g transform=\"translate(264.095231 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-38\" d=\"M 2034 2216 \n",
       "Q 1584 2216 1326 1975 \n",
       "Q 1069 1734 1069 1313 \n",
       "Q 1069 891 1326 650 \n",
       "Q 1584 409 2034 409 \n",
       "Q 2484 409 2743 651 \n",
       "Q 3003 894 3003 1313 \n",
       "Q 3003 1734 2745 1975 \n",
       "Q 2488 2216 2034 2216 \n",
       "z\n",
       "M 1403 2484 \n",
       "Q 997 2584 770 2862 \n",
       "Q 544 3141 544 3541 \n",
       "Q 544 4100 942 4425 \n",
       "Q 1341 4750 2034 4750 \n",
       "Q 2731 4750 3128 4425 \n",
       "Q 3525 4100 3525 3541 \n",
       "Q 3525 3141 3298 2862 \n",
       "Q 3072 2584 2669 2484 \n",
       "Q 3125 2378 3379 2068 \n",
       "Q 3634 1759 3634 1313 \n",
       "Q 3634 634 3220 271 \n",
       "Q 2806 -91 2034 -91 \n",
       "Q 1263 -91 848 271 \n",
       "Q 434 634 434 1313 \n",
       "Q 434 1759 690 2068 \n",
       "Q 947 2378 1403 2484 \n",
       "z\n",
       "M 1172 3481 \n",
       "Q 1172 3119 1398 2916 \n",
       "Q 1625 2713 2034 2713 \n",
       "Q 2441 2713 2670 2916 \n",
       "Q 2900 3119 2900 3481 \n",
       "Q 2900 3844 2670 4047 \n",
       "Q 2441 4250 2034 4250 \n",
       "Q 1625 4250 1398 4047 \n",
       "Q 1172 3844 1172 3481 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-38\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdcd4386473\" x=\"378.634832\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 2012 -->\n",
       "      <g transform=\"translate(365.909832 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdcd4386473\" x=\"480.449434\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 2016 -->\n",
       "      <g transform=\"translate(467.724434 354.438437) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-36\" d=\"M 2113 2584 \n",
       "Q 1688 2584 1439 2293 \n",
       "Q 1191 2003 1191 1497 \n",
       "Q 1191 994 1439 701 \n",
       "Q 1688 409 2113 409 \n",
       "Q 2538 409 2786 701 \n",
       "Q 3034 994 3034 1497 \n",
       "Q 3034 2003 2786 2293 \n",
       "Q 2538 2584 2113 2584 \n",
       "z\n",
       "M 3366 4563 \n",
       "L 3366 3988 \n",
       "Q 3128 4100 2886 4159 \n",
       "Q 2644 4219 2406 4219 \n",
       "Q 1781 4219 1451 3797 \n",
       "Q 1122 3375 1075 2522 \n",
       "Q 1259 2794 1537 2939 \n",
       "Q 1816 3084 2150 3084 \n",
       "Q 2853 3084 3261 2657 \n",
       "Q 3669 2231 3669 1497 \n",
       "Q 3669 778 3244 343 \n",
       "Q 2819 -91 2113 -91 \n",
       "Q 1303 -91 875 529 \n",
       "Q 447 1150 447 2328 \n",
       "Q 447 3434 972 4092 \n",
       "Q 1497 4750 2381 4750 \n",
       "Q 2619 4750 2861 4703 \n",
       "Q 3103 4656 3366 4563 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdcd4386473\" x=\"582.264036\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 2020 -->\n",
       "      <g transform=\"translate(569.539036 354.438437) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mdcd4386473\" x=\"684.078637\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 2024 -->\n",
       "      <g transform=\"translate(671.353637 354.438437) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <defs>\n",
       "       <path id=\"mb52960ef1e\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb52960ef1e\" x=\"44.845313\" y=\"323.61431\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- −0.10 -->\n",
       "      <g transform=\"translate(7.2 327.413529) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2212\" d=\"M 678 2272 \n",
       "L 4684 2272 \n",
       "L 4684 1741 \n",
       "L 678 1741 \n",
       "L 678 2272 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"83.789062\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"147.412109\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"179.199219\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"242.822266\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb52960ef1e\" x=\"44.845313\" y=\"264.167889\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- −0.05 -->\n",
       "      <g transform=\"translate(7.2 267.967107) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"83.789062\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"147.412109\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"179.199219\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"242.822266\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb52960ef1e\" x=\"44.845313\" y=\"204.721467\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 0.00 -->\n",
       "      <g transform=\"translate(15.579688 208.520686) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb52960ef1e\" x=\"44.845313\" y=\"145.275046\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 0.05 -->\n",
       "      <g transform=\"translate(15.579688 149.074265) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb52960ef1e\" x=\"44.845313\" y=\"85.828624\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 0.10 -->\n",
       "      <g transform=\"translate(15.579688 89.627843) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mb52960ef1e\" x=\"44.845313\" y=\"26.382203\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 0.15 -->\n",
       "      <g transform=\"translate(15.579688 30.181422) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_14\">\n",
       "    <path d=\"M 75.281676 271.230721 \n",
       "L 77.302637 284.866141 \n",
       "L 79.462974 198.793959 \n",
       "L 81.553623 187.95994 \n",
       "L 83.71396 186.717234 \n",
       "L 85.804609 114.243705 \n",
       "L 87.964946 182.037787 \n",
       "L 90.125283 244.619212 \n",
       "L 92.215932 236.22692 \n",
       "L 94.376269 199.385008 \n",
       "L 96.466918 181.074346 \n",
       "L 98.627256 175.903065 \n",
       "L 100.787593 161.3966 \n",
       "L 102.738865 166.370886 \n",
       "L 104.899202 215.494902 \n",
       "L 106.989851 239.835428 \n",
       "L 109.150188 253.050724 \n",
       "L 111.240837 181.136545 \n",
       "L 113.401174 204.833424 \n",
       "L 115.561512 213.924797 \n",
       "L 117.652161 164.945861 \n",
       "L 119.812498 191.062214 \n",
       "L 121.903147 184.213329 \n",
       "L 124.063484 171.630465 \n",
       "L 126.223821 196.312439 \n",
       "L 128.175093 186.144544 \n",
       "L 130.335431 216.152804 \n",
       "L 132.42608 226.84081 \n",
       "L 134.586417 236.564878 \n",
       "L 136.677066 177.356489 \n",
       "L 138.837403 203.312986 \n",
       "L 140.99774 194.443065 \n",
       "L 143.088389 200.903123 \n",
       "L 145.248726 212.212914 \n",
       "L 147.339375 185.595014 \n",
       "L 149.499712 198.304933 \n",
       "L 151.660049 177.403837 \n",
       "L 153.611322 207.884938 \n",
       "L 155.771659 177.172263 \n",
       "L 157.862308 150.272494 \n",
       "L 160.022645 212.271278 \n",
       "L 162.113294 163.991902 \n",
       "L 164.273631 173.691669 \n",
       "L 166.433968 213.372814 \n",
       "L 168.524617 202.946895 \n",
       "L 170.684954 94.332046 \n",
       "L 172.775603 187.648688 \n",
       "L 174.935941 83.324989 \n",
       "L 177.096278 214.211134 \n",
       "L 179.117238 228.137966 \n",
       "L 181.277576 174.572648 \n",
       "L 183.368225 133.145276 \n",
       "L 185.528562 215.348085 \n",
       "L 187.619211 147.78819 \n",
       "L 189.779548 194.444496 \n",
       "L 191.939885 150.19431 \n",
       "L 194.030534 170.016094 \n",
       "L 196.190871 177.0995 \n",
       "L 198.28152 237.79121 \n",
       "L 200.441857 150.664104 \n",
       "L 202.602194 175.405682 \n",
       "L 204.553467 177.985984 \n",
       "L 206.713804 151.238684 \n",
       "L 208.804453 161.479612 \n",
       "L 210.96479 265.678395 \n",
       "L 213.055439 147.057287 \n",
       "L 215.215776 126.272113 \n",
       "L 217.376113 237.954276 \n",
       "L 219.466762 190.399369 \n",
       "L 221.627099 198.302321 \n",
       "L 223.717748 214.313826 \n",
       "L 225.878086 162.268841 \n",
       "L 228.038423 197.245005 \n",
       "L 229.989695 200.321013 \n",
       "L 232.150032 190.021079 \n",
       "L 234.240681 222.890709 \n",
       "L 236.401018 243.528962 \n",
       "L 238.491667 168.046303 \n",
       "L 240.652004 204.042089 \n",
       "L 244.902991 228.786864 \n",
       "L 247.063328 106.931712 \n",
       "L 249.153977 110.499175 \n",
       "L 251.314314 171.122072 \n",
       "L 253.474651 216.718798 \n",
       "L 255.425923 247.685996 \n",
       "L 257.586261 238.668914 \n",
       "L 259.67691 302.107353 \n",
       "L 261.837247 170.861459 \n",
       "L 263.927896 64.600377 \n",
       "L 266.088233 201.871034 \n",
       "L 268.24857 140.461999 \n",
       "L 270.339219 142.730337 \n",
       "L 272.499556 94.106017 \n",
       "L 274.590205 200.184638 \n",
       "L 276.750542 227.816401 \n",
       "L 278.910879 199.960037 \n",
       "L 280.93184 200.852062 \n",
       "L 283.092177 208.278421 \n",
       "L 285.182826 115.695063 \n",
       "L 287.343163 220.902479 \n",
       "L 289.433812 208.627358 \n",
       "L 291.594149 194.690365 \n",
       "L 293.754487 122.127403 \n",
       "L 295.845136 255.761445 \n",
       "L 298.005473 158.542231 \n",
       "L 300.096122 161.181564 \n",
       "L 302.256459 202.532503 \n",
       "L 304.416796 144.357579 \n",
       "L 306.368068 245.442805 \n",
       "L 310.619054 170.949769 \n",
       "L 312.779392 226.567488 \n",
       "L 314.870041 154.850522 \n",
       "L 317.030378 292.157358 \n",
       "L 319.190715 178.010766 \n",
       "L 321.281364 154.129388 \n",
       "L 323.441701 222.408993 \n",
       "L 325.53235 232.447953 \n",
       "L 327.692687 183.140916 \n",
       "L 329.853024 171.27186 \n",
       "L 331.804297 234.7709 \n",
       "L 333.964634 195.910095 \n",
       "L 336.055283 205.546186 \n",
       "L 338.21562 195.482541 \n",
       "L 340.306269 156.525211 \n",
       "L 342.466606 208.22028 \n",
       "L 344.626943 271.798476 \n",
       "L 346.717592 242.089677 \n",
       "L 348.877929 192.938882 \n",
       "L 350.968578 213.40916 \n",
       "L 353.128916 162.678647 \n",
       "L 355.289253 146.345904 \n",
       "L 357.240525 272.051437 \n",
       "L 359.400862 182.681897 \n",
       "L 361.491511 180.743466 \n",
       "L 363.651848 193.224829 \n",
       "L 365.742497 204.442645 \n",
       "L 367.902834 227.305618 \n",
       "L 370.063172 196.821621 \n",
       "L 372.153821 153.451487 \n",
       "L 374.314158 193.478877 \n",
       "L 376.404807 220.248228 \n",
       "L 378.565144 82.678017 \n",
       "L 380.725481 160.304125 \n",
       "L 382.746442 238.818333 \n",
       "L 384.906779 182.007167 \n",
       "L 386.997428 196.352835 \n",
       "L 389.157765 216.139389 \n",
       "L 391.248414 165.976859 \n",
       "L 393.408751 163.268403 \n",
       "L 395.569088 218.464184 \n",
       "L 399.820074 190.18102 \n",
       "L 401.910723 133.459356 \n",
       "L 404.071061 209.629462 \n",
       "L 406.231398 203.924996 \n",
       "L 408.18267 221.187236 \n",
       "L 410.343007 211.981498 \n",
       "L 412.433656 187.852218 \n",
       "L 414.593993 253.252897 \n",
       "L 416.684642 162.114709 \n",
       "L 418.844979 246.092448 \n",
       "L 421.005317 192.169434 \n",
       "L 423.095966 234.021857 \n",
       "L 425.256303 142.619348 \n",
       "L 427.346952 237.490669 \n",
       "L 429.507289 163.295729 \n",
       "L 431.667626 277.909716 \n",
       "L 433.618898 221.070819 \n",
       "L 435.779236 132.362107 \n",
       "L 437.869884 182.560405 \n",
       "L 440.030222 242.36896 \n",
       "L 442.120871 230.807101 \n",
       "L 444.281208 167.322736 \n",
       "L 446.441545 248.98205 \n",
       "L 448.532194 237.594168 \n",
       "L 450.692531 175.709835 \n",
       "L 452.78318 143.937434 \n",
       "L 454.943517 22.32 \n",
       "L 457.103854 245.667758 \n",
       "L 459.055127 251.120681 \n",
       "L 461.215464 268.127297 \n",
       "L 463.306113 222.388624 \n",
       "L 465.46645 324.72 \n",
       "L 467.557099 103.211573 \n",
       "L 469.717436 112.650107 \n",
       "L 471.877773 160.798249 \n",
       "L 473.968422 177.13774 \n",
       "L 476.128759 298.561201 \n",
       "L 478.219408 199.542471 \n",
       "L 480.379746 173.30463 \n",
       "L 482.540083 125.377657 \n",
       "L 484.561043 194.72853 \n",
       "L 486.721381 211.395164 \n",
       "L 488.812029 189.604137 \n",
       "L 490.972367 178.008417 \n",
       "L 493.063016 217.63537 \n",
       "L 495.223353 141.866389 \n",
       "L 497.38369 206.611342 \n",
       "L 499.474339 192.261109 \n",
       "L 501.634676 215.73279 \n",
       "L 503.725325 195.18992 \n",
       "L 505.885662 205.686009 \n",
       "L 508.045999 186.227259 \n",
       "L 509.997272 203.660637 \n",
       "L 512.157609 168.187764 \n",
       "L 514.248258 140.407362 \n",
       "L 516.408595 144.118208 \n",
       "L 518.499244 182.696603 \n",
       "L 520.659581 169.494171 \n",
       "L 522.819918 224.037836 \n",
       "L 524.910567 223.411646 \n",
       "L 527.070904 161.637631 \n",
       "L 529.161553 172.349094 \n",
       "L 531.321891 181.881168 \n",
       "L 533.482228 100.053488 \n",
       "L 535.4335 222.879209 \n",
       "L 537.593837 287.921253 \n",
       "L 539.684486 214.368733 \n",
       "L 541.844823 179.838398 \n",
       "L 543.935472 159.234813 \n",
       "L 546.095809 165.182298 \n",
       "L 548.256147 196.096916 \n",
       "L 550.346796 180.463148 \n",
       "L 552.507133 159.039049 \n",
       "L 554.597782 240.949184 \n",
       "L 556.758119 192.223211 \n",
       "L 558.918456 155.801317 \n",
       "L 560.869728 318.884542 \n",
       "L 563.030066 252.1992 \n",
       "L 565.120714 168.787993 \n",
       "L 567.281052 202.27215 \n",
       "L 569.371701 162.733377 \n",
       "L 571.532038 195.685476 \n",
       "L 573.692375 260.101781 \n",
       "L 575.783024 185.311042 \n",
       "L 577.943361 203.373658 \n",
       "L 580.03401 192.098782 \n",
       "L 582.194347 211.654695 \n",
       "L 584.354684 258.443881 \n",
       "L 586.375645 273.474631 \n",
       "L 588.535982 128.446121 \n",
       "L 590.626631 212.591913 \n",
       "L 592.786968 221.462461 \n",
       "L 594.877617 240.699881 \n",
       "L 597.037954 219.422646 \n",
       "L 599.198292 158.828085 \n",
       "L 601.288941 195.92563 \n",
       "L 603.449278 207.6057 \n",
       "L 605.539927 158.91428 \n",
       "L 607.700264 268.183518 \n",
       "L 609.860601 181.537194 \n",
       "L 611.811873 134.497289 \n",
       "L 613.972211 150.548468 \n",
       "L 616.062859 285.299829 \n",
       "L 618.223197 262.98867 \n",
       "L 620.313846 271.004863 \n",
       "L 622.474183 263.309417 \n",
       "L 624.63452 153.224197 \n",
       "L 626.725169 128.549946 \n",
       "L 628.885506 262.907124 \n",
       "L 630.976155 251.976803 \n",
       "L 633.136492 127.931974 \n",
       "L 635.296829 130.757938 \n",
       "L 637.248102 196.866464 \n",
       "L 639.408439 155.405084 \n",
       "L 641.499088 117.664833 \n",
       "L 643.659425 246.036844 \n",
       "L 645.750074 242.946496 \n",
       "L 647.910411 232.431478 \n",
       "L 650.070748 160.480224 \n",
       "L 652.161397 167.724928 \n",
       "L 654.321734 258.696801 \n",
       "L 656.412383 159.482696 \n",
       "L 658.572721 196.267728 \n",
       "L 660.733058 185.848763 \n",
       "L 662.68433 199.043421 \n",
       "L 664.844667 220.672999 \n",
       "L 666.935316 145.080268 \n",
       "L 669.095653 215.255183 \n",
       "L 671.186302 181.826491 \n",
       "L 673.346639 165.640366 \n",
       "L 675.506977 195.426865 \n",
       "L 677.597626 189.36481 \n",
       "L 679.757963 245.330403 \n",
       "L 681.848612 220.188209 \n",
       "L 684.008949 177.830588 \n",
       "L 684.008949 177.830588 \n",
       "\" clip-path=\"url(#pc2b937e8da)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 44.845313 339.84 \n",
       "L 44.845313 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 714.445312 339.84 \n",
       "L 714.445312 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 44.845312 339.84 \n",
       "L 714.445312 339.84 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 44.845312 7.2 \n",
       "L 714.445312 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 51.845313 29.878125 \n",
       "L 105.565625 29.878125 \n",
       "Q 107.565625 29.878125 107.565625 27.878125 \n",
       "L 107.565625 14.2 \n",
       "Q 107.565625 12.2 105.565625 12.2 \n",
       "L 51.845313 12.2 \n",
       "Q 49.845313 12.2 49.845313 14.2 \n",
       "L 49.845313 27.878125 \n",
       "Q 49.845313 29.878125 51.845313 29.878125 \n",
       "z\n",
       "\" style=\"fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_15\">\n",
       "     <path d=\"M 53.845313 20.298437 \n",
       "L 63.845313 20.298437 \n",
       "L 73.845313 20.298437 \n",
       "\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    </g>\n",
       "    <g id=\"text_14\">\n",
       "     <!-- HML -->\n",
       "     <g transform=\"translate(81.845313 23.798437) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-48\" d=\"M 628 4666 \n",
       "L 1259 4666 \n",
       "L 1259 2753 \n",
       "L 3553 2753 \n",
       "L 3553 4666 \n",
       "L 4184 4666 \n",
       "L 4184 0 \n",
       "L 3553 0 \n",
       "L 3553 2222 \n",
       "L 1259 2222 \n",
       "L 1259 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-4d\" d=\"M 628 4666 \n",
       "L 1569 4666 \n",
       "L 2759 1491 \n",
       "L 3956 4666 \n",
       "L 4897 4666 \n",
       "L 4897 0 \n",
       "L 4281 0 \n",
       "L 4281 4097 \n",
       "L 3078 897 \n",
       "L 2444 897 \n",
       "L 1241 4097 \n",
       "L 1241 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-4c\" d=\"M 628 4666 \n",
       "L 1259 4666 \n",
       "L 1259 531 \n",
       "L 3531 531 \n",
       "L 3531 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-4d\" x=\"75.195312\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-4c\" x=\"161.474609\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pc2b937e8da\">\n",
       "   <rect x=\"44.845313\" y=\"7.2\" width=\"669.6\" height=\"332.64\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 1200x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(12,6))\n",
    "plt.plot(factors['HML'], label='HML')\n",
    "plt.legend(loc='upper left')\n",
    "plt.show();\n",
    "# plot HML"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SMB</th>\n",
       "      <th>HML</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>204.000000</td>\n",
       "      <td>204.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.008493</td>\n",
       "      <td>0.009769</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.043100</td>\n",
       "      <td>0.037199</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>-0.177738</td>\n",
       "      <td>-0.100930</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>-0.012872</td>\n",
       "      <td>-0.011036</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>0.006842</td>\n",
       "      <td>0.007894</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>0.028960</td>\n",
       "      <td>0.030999</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>0.157663</td>\n",
       "      <td>0.153417</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              SMB         HML\n",
       "count  204.000000  204.000000\n",
       "mean     0.008493    0.009769\n",
       "std      0.043100    0.037199\n",
       "min     -0.177738   -0.100930\n",
       "25%     -0.012872   -0.011036\n",
       "50%      0.006842    0.007894\n",
       "75%      0.028960    0.030999\n",
       "max      0.157663    0.153417"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SMB</th>\n",
       "      <th>HML</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>SMB</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.565336</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HML</th>\n",
       "      <td>-0.565336</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          SMB       HML\n",
       "SMB  1.000000 -0.565336\n",
       "HML -0.565336  1.000000"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# summary of the factor\n",
    "factors[:'2016-12'].describe()\n",
    "factors[:'2016-12'].corr()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "上面这个表格显示的是SMB（Small Minus Big，小市值股票减去大市值股票的收益率）和HML（High Minus Low，高账面市值比股票减去低账面市值比股票的收益率）之间的相关系数矩阵。\n",
    "1. **SMB与自身的相关性**：SMB与自身的相关系数是1.000000，这是预期的，因为任何变量与自身的相关性总是完美的（即相关系数为1）。\n",
    "2. **HML与自身的相关性**：同样，HML与自身的相关系数也是1.000000。\n",
    "3. **SMB与HML之间的相关性**：SMB与HML之间的相关系数是-0.565336。这个值表明两者之间存在中等程度的负相关关系。负相关意味着当一个变量的值增加时，另一个变量的值倾向于减少。在这个特定的上下文中，如果小市值股票的表现相对于大市值股票的表现增加，那么高账面市值比股票相对于低账面市值比股票的表现可能会减少，反之亦然。\n",
    "这种负相关性可能对投资组合构建和风险管理有重要意义。例如，如果一个投资者在构建投资组合时考虑了这两个因子，他们可能会发现通过同时投资于SMB和HML，可以在一定程度上分散风险，因为这两个因子的负相关性可能会减少组合的总体波动性。\n",
    "此外，这个相关系数矩阵可以作为进一步分析的起点，例如在构建多因子模型时，了解不同因子之间的相关性是重要的，因为它可以帮助避免过度依赖高度相关的因子，从而可能导致模型过度拟合或者在样本外表现不佳。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                            OLS Regression Results                            \n",
      "==============================================================================\n",
      "Dep. Variable:                    SMB   R-squared:                       0.000\n",
      "Model:                            OLS   Adj. R-squared:                  0.000\n",
      "Method:                 Least Squares   F-statistic:                       nan\n",
      "Date:                Tue, 17 Dec 2024   Prob (F-statistic):                nan\n",
      "Time:                        20:29:56   Log-Likelihood:                 352.46\n",
      "No. Observations:                 204   AIC:                            -702.9\n",
      "Df Residuals:                     203   BIC:                            -699.6\n",
      "Df Model:                           0                                         \n",
      "Covariance Type:                  HAC                                         \n",
      "==============================================================================\n",
      "                 coef    std err          z      P>|z|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "Intercept      0.0085      0.003      2.712      0.007       0.002       0.015\n",
      "==============================================================================\n",
      "Omnibus:                       14.562   Durbin-Watson:                   1.863\n",
      "Prob(Omnibus):                  0.001   Jarque-Bera (JB):               41.875\n",
      "Skew:                          -0.066   Prob(JB):                     8.07e-10\n",
      "Kurtosis:                       5.216   Cond. No.                         1.00\n",
      "==============================================================================\n",
      "\n",
      "Notes:\n",
      "[1] Standard Errors are heteroscedasticity and autocorrelation robust (HAC) using 2 lags and without small sample correction\n"
     ]
    }
   ],
   "source": [
    "# regression\n",
    "model = smf.ols('SMB ~ 1',\n",
    "                 data=factors['2000-01':'2016-12']).fit(\n",
    "                     cov_type='HAC', cov_kwds={'maxlags': 2})\n",
    "print(model.summary())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                            OLS Regression Results                            \n",
      "==============================================================================\n",
      "Dep. Variable:                    HML   R-squared:                       0.000\n",
      "Model:                            OLS   Adj. R-squared:                  0.000\n",
      "Method:                 Least Squares   F-statistic:                       nan\n",
      "Date:                Tue, 17 Dec 2024   Prob (F-statistic):                nan\n",
      "Time:                        20:30:09   Log-Likelihood:                 382.50\n",
      "No. Observations:                 204   AIC:                            -763.0\n",
      "Df Residuals:                     203   BIC:                            -759.7\n",
      "Df Model:                           0                                         \n",
      "Covariance Type:                  HAC                                         \n",
      "==============================================================================\n",
      "                 coef    std err          z      P>|z|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "Intercept      0.0098      0.003      3.828      0.000       0.005       0.015\n",
      "==============================================================================\n",
      "Omnibus:                       10.677   Durbin-Watson:                   1.938\n",
      "Prob(Omnibus):                  0.005   Jarque-Bera (JB):               15.469\n",
      "Skew:                           0.327   Prob(JB):                     0.000437\n",
      "Kurtosis:                       4.180   Cond. No.                         1.00\n",
      "==============================================================================\n",
      "\n",
      "Notes:\n",
      "[1] Standard Errors are heteroscedasticity and autocorrelation robust (HAC) using 2 lags and without small sample correction\n"
     ]
    }
   ],
   "source": [
    "# regression\n",
    "model = smf.ols('HML ~ 1',\n",
    "                 data=factors['2000-01':'2016-12']).fit(\n",
    "                     cov_type='HAC', cov_kwds={'maxlags': 2})\n",
    "print(model.summary())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## price of the picture"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"703.725pt\" height=\"379.49pt\" viewBox=\"0 0 703.725 379.49\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2024-12-17T20:30:47.635154</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.8.4, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 379.49 \n",
       "L 703.725 379.49 \n",
       "L 703.725 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 26.925 339.84 \n",
       "L 696.525 339.84 \n",
       "L 696.525 7.2 \n",
       "L 26.925 7.2 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path id=\"m6c3fb7fa30\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"57.361364\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 2000 -->\n",
       "      <g transform=\"translate(60.120739 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"82.86728\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 2001 -->\n",
       "      <g transform=\"translate(85.626655 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"108.303509\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 2002 -->\n",
       "      <g transform=\"translate(111.062884 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"133.739737\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 2003 -->\n",
       "      <g transform=\"translate(136.499112 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"159.175965\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 2004 -->\n",
       "      <g transform=\"translate(161.93534 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"184.681882\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 2005 -->\n",
       "      <g transform=\"translate(187.441257 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"210.11811\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 2006 -->\n",
       "      <g transform=\"translate(212.877485 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-36\" d=\"M 2113 2584 \n",
       "Q 1688 2584 1439 2293 \n",
       "Q 1191 2003 1191 1497 \n",
       "Q 1191 994 1439 701 \n",
       "Q 1688 409 2113 409 \n",
       "Q 2538 409 2786 701 \n",
       "Q 3034 994 3034 1497 \n",
       "Q 3034 2003 2786 2293 \n",
       "Q 2538 2584 2113 2584 \n",
       "z\n",
       "M 3366 4563 \n",
       "L 3366 3988 \n",
       "Q 3128 4100 2886 4159 \n",
       "Q 2644 4219 2406 4219 \n",
       "Q 1781 4219 1451 3797 \n",
       "Q 1122 3375 1075 2522 \n",
       "Q 1259 2794 1537 2939 \n",
       "Q 1816 3084 2150 3084 \n",
       "Q 2853 3084 3261 2657 \n",
       "Q 3669 2231 3669 1497 \n",
       "Q 3669 778 3244 343 \n",
       "Q 2819 -91 2113 -91 \n",
       "Q 1303 -91 875 529 \n",
       "Q 447 1150 447 2328 \n",
       "Q 447 3434 972 4092 \n",
       "Q 1497 4750 2381 4750 \n",
       "Q 2619 4750 2861 4703 \n",
       "Q 3103 4656 3366 4563 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"235.554339\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 2007 -->\n",
       "      <g transform=\"translate(238.313714 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-37\" d=\"M 525 4666 \n",
       "L 3525 4666 \n",
       "L 3525 4397 \n",
       "L 1831 0 \n",
       "L 1172 0 \n",
       "L 2766 4134 \n",
       "L 525 4134 \n",
       "L 525 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-37\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_9\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"260.990567\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 2008 -->\n",
       "      <g transform=\"translate(263.749942 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-38\" d=\"M 2034 2216 \n",
       "Q 1584 2216 1326 1975 \n",
       "Q 1069 1734 1069 1313 \n",
       "Q 1069 891 1326 650 \n",
       "Q 1584 409 2034 409 \n",
       "Q 2484 409 2743 651 \n",
       "Q 3003 894 3003 1313 \n",
       "Q 3003 1734 2745 1975 \n",
       "Q 2488 2216 2034 2216 \n",
       "z\n",
       "M 1403 2484 \n",
       "Q 997 2584 770 2862 \n",
       "Q 544 3141 544 3541 \n",
       "Q 544 4100 942 4425 \n",
       "Q 1341 4750 2034 4750 \n",
       "Q 2731 4750 3128 4425 \n",
       "Q 3525 4100 3525 3541 \n",
       "Q 3525 3141 3298 2862 \n",
       "Q 3072 2584 2669 2484 \n",
       "Q 3125 2378 3379 2068 \n",
       "Q 3634 1759 3634 1313 \n",
       "Q 3634 634 3220 271 \n",
       "Q 2806 -91 2034 -91 \n",
       "Q 1263 -91 848 271 \n",
       "Q 434 634 434 1313 \n",
       "Q 434 1759 690 2068 \n",
       "Q 947 2378 1403 2484 \n",
       "z\n",
       "M 1172 3481 \n",
       "Q 1172 3119 1398 2916 \n",
       "Q 1625 2713 2034 2713 \n",
       "Q 2441 2713 2670 2916 \n",
       "Q 2900 3119 2900 3481 \n",
       "Q 2900 3844 2670 4047 \n",
       "Q 2441 4250 2034 4250 \n",
       "Q 1625 4250 1398 4047 \n",
       "Q 1172 3844 1172 3481 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-38\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_10\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"286.496484\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 2009 -->\n",
       "      <g transform=\"translate(289.255859 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-39\" d=\"M 703 97 \n",
       "L 703 672 \n",
       "Q 941 559 1184 500 \n",
       "Q 1428 441 1663 441 \n",
       "Q 2288 441 2617 861 \n",
       "Q 2947 1281 2994 2138 \n",
       "Q 2813 1869 2534 1725 \n",
       "Q 2256 1581 1919 1581 \n",
       "Q 1219 1581 811 2004 \n",
       "Q 403 2428 403 3163 \n",
       "Q 403 3881 828 4315 \n",
       "Q 1253 4750 1959 4750 \n",
       "Q 2769 4750 3195 4129 \n",
       "Q 3622 3509 3622 2328 \n",
       "Q 3622 1225 3098 567 \n",
       "Q 2575 -91 1691 -91 \n",
       "Q 1453 -91 1209 -44 \n",
       "Q 966 3 703 97 \n",
       "z\n",
       "M 1959 2075 \n",
       "Q 2384 2075 2632 2365 \n",
       "Q 2881 2656 2881 3163 \n",
       "Q 2881 3666 2632 3958 \n",
       "Q 2384 4250 1959 4250 \n",
       "Q 1534 4250 1286 3958 \n",
       "Q 1038 3666 1038 3163 \n",
       "Q 1038 2656 1286 2365 \n",
       "Q 1534 2075 1959 2075 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-39\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_11\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"311.932712\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 2010 -->\n",
       "      <g transform=\"translate(314.692087 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_12\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"337.36894\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 2011 -->\n",
       "      <g transform=\"translate(340.128315 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_13\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"362.805169\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 2012 -->\n",
       "      <g transform=\"translate(365.564544 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_14\">\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"388.311085\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 2013 -->\n",
       "      <g transform=\"translate(391.07046 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_15\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"413.747314\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_15\">\n",
       "      <!-- 2014 -->\n",
       "      <g transform=\"translate(416.506689 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_16\">\n",
       "     <g id=\"line2d_16\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"439.183542\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_16\">\n",
       "      <!-- 2015 -->\n",
       "      <g transform=\"translate(441.942917 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-35\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_17\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"464.61977\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_17\">\n",
       "      <!-- 2016 -->\n",
       "      <g transform=\"translate(467.379145 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_18\">\n",
       "     <g id=\"line2d_18\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"490.125687\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_18\">\n",
       "      <!-- 2017 -->\n",
       "      <g transform=\"translate(492.885062 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-37\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_19\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"515.561915\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_19\">\n",
       "      <!-- 2018 -->\n",
       "      <g transform=\"translate(518.32129 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-38\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_20\">\n",
       "     <g id=\"line2d_20\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"540.998144\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_20\">\n",
       "      <!-- 2019 -->\n",
       "      <g transform=\"translate(543.757519 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-39\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_21\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"566.434372\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_21\">\n",
       "      <!-- 2020 -->\n",
       "      <g transform=\"translate(569.193747 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_22\">\n",
       "     <g id=\"line2d_22\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"591.940289\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_22\">\n",
       "      <!-- 2021 -->\n",
       "      <g transform=\"translate(594.699664 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_23\">\n",
       "     <g id=\"line2d_23\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"617.376517\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_23\">\n",
       "      <!-- 2022 -->\n",
       "      <g transform=\"translate(620.135892 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_24\">\n",
       "     <g id=\"line2d_24\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m6c3fb7fa30\" x=\"642.812745\" y=\"339.84\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_24\">\n",
       "      <!-- 2023 -->\n",
       "      <g transform=\"translate(645.57212 372.29) rotate(-90) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"127.246094\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"190.869141\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_25\">\n",
       "      <defs>\n",
       "       <path id=\"m0d6018beb2\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m0d6018beb2\" x=\"26.925\" y=\"287.798072\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_25\">\n",
       "      <!-- 2 -->\n",
       "      <g transform=\"translate(13.5625 291.597291) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_26\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m0d6018beb2\" x=\"26.925\" y=\"222.948542\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_26\">\n",
       "      <!-- 4 -->\n",
       "      <g transform=\"translate(13.5625 226.747761) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_27\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m0d6018beb2\" x=\"26.925\" y=\"158.099012\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_27\">\n",
       "      <!-- 6 -->\n",
       "      <g transform=\"translate(13.5625 161.89823) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_28\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m0d6018beb2\" x=\"26.925\" y=\"93.249482\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_28\">\n",
       "      <!-- 8 -->\n",
       "      <g transform=\"translate(13.5625 97.0487) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_29\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m0d6018beb2\" x=\"26.925\" y=\"28.399951\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_29\">\n",
       "      <!-- 10 -->\n",
       "      <g transform=\"translate(7.2 32.19917) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"63.623047\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_30\">\n",
       "    <path d=\"M 57.361364 320.716135 \n",
       "L 59.382324 320.15213 \n",
       "L 61.542661 317.642917 \n",
       "L 63.63331 318.062716 \n",
       "L 65.793648 317.205114 \n",
       "L 67.884296 316.95453 \n",
       "L 70.044634 316.218761 \n",
       "L 72.204971 315.639324 \n",
       "L 74.29562 315.206621 \n",
       "L 76.455957 314.123622 \n",
       "L 78.546606 313.60673 \n",
       "L 80.706943 312.920013 \n",
       "L 82.86728 312.663547 \n",
       "L 84.818553 312.951409 \n",
       "L 86.97889 312.292302 \n",
       "L 89.069539 312.007193 \n",
       "L 93.320525 310.520928 \n",
       "L 95.480862 310.84574 \n",
       "L 97.641199 310.871255 \n",
       "L 101.892185 311.940416 \n",
       "L 103.982834 311.07496 \n",
       "L 106.143171 311.594905 \n",
       "L 108.303509 313.326227 \n",
       "L 112.415118 311.511728 \n",
       "L 114.505767 310.934605 \n",
       "L 116.666104 311.431502 \n",
       "L 118.756753 312.367021 \n",
       "L 120.91709 312.10081 \n",
       "L 123.077428 312.071448 \n",
       "L 125.168076 312.351249 \n",
       "L 127.328414 312.75612 \n",
       "L 129.419063 314.211184 \n",
       "L 131.5794 314.385664 \n",
       "L 133.739737 313.89425 \n",
       "L 135.691009 313.644727 \n",
       "L 137.851346 314.903818 \n",
       "L 139.941995 316.821107 \n",
       "L 142.102333 317.148991 \n",
       "L 144.192981 317.341914 \n",
       "L 146.353319 318.37001 \n",
       "L 148.513656 318.13185 \n",
       "L 150.604305 318.077366 \n",
       "L 152.764642 319.603835 \n",
       "L 154.855291 319.392294 \n",
       "L 157.015628 321.644354 \n",
       "L 159.175965 320.220949 \n",
       "L 161.196926 319.065355 \n",
       "L 163.357263 318.656673 \n",
       "L 165.447912 318.102243 \n",
       "L 167.608249 317.746745 \n",
       "L 169.698898 318.63874 \n",
       "L 171.859235 319.031322 \n",
       "L 174.019573 319.00767 \n",
       "L 176.110221 318.79196 \n",
       "L 178.270559 319.164361 \n",
       "L 180.361208 317.918181 \n",
       "L 182.521545 318.538408 \n",
       "L 184.681882 318.971276 \n",
       "L 186.633154 318.380803 \n",
       "L 188.793491 319.593364 \n",
       "L 190.88414 321.644766 \n",
       "L 193.044478 320.119839 \n",
       "L 195.135126 320.964988 \n",
       "L 197.295464 323.272983 \n",
       "L 199.455801 321.006874 \n",
       "L 201.54645 320.123077 \n",
       "L 203.706787 320.541456 \n",
       "L 205.797436 320.323151 \n",
       "L 207.957773 321.481553 \n",
       "L 210.11811 321.206493 \n",
       "L 212.069383 321.54007 \n",
       "L 214.22972 321.629374 \n",
       "L 216.320369 322.854971 \n",
       "L 218.480706 319.651082 \n",
       "L 220.571355 318.250353 \n",
       "L 222.731692 317.018526 \n",
       "L 224.892029 317.260656 \n",
       "L 226.982678 317.802127 \n",
       "L 229.143015 318.146879 \n",
       "L 231.233664 321.500479 \n",
       "L 233.394001 324.72 \n",
       "L 235.554339 322.432211 \n",
       "L 237.505611 318.618361 \n",
       "L 239.665948 316.224152 \n",
       "L 241.756597 314.086271 \n",
       "L 243.916934 315.113201 \n",
       "L 246.007583 317.634565 \n",
       "L 248.16792 315.536341 \n",
       "L 250.328258 316.959385 \n",
       "L 252.418906 317.602245 \n",
       "L 254.579244 321.352635 \n",
       "L 256.669893 318.080301 \n",
       "L 258.83023 316.336511 \n",
       "L 260.990567 313.7264 \n",
       "L 263.011528 310.710595 \n",
       "L 265.171865 310.669745 \n",
       "L 267.262514 313.460979 \n",
       "L 269.422851 312.273795 \n",
       "L 271.5135 314.012351 \n",
       "L 273.673837 311.344111 \n",
       "L 275.834174 312.629392 \n",
       "L 277.924823 314.642218 \n",
       "L 280.08516 314.612559 \n",
       "L 282.175809 309.451625 \n",
       "L 284.336146 307.212289 \n",
       "L 286.496484 303.375903 \n",
       "L 288.447756 301.943972 \n",
       "L 290.608093 298.962401 \n",
       "L 294.859079 296.59682 \n",
       "L 296.949728 301.497097 \n",
       "L 299.110065 304.623116 \n",
       "L 301.270403 300.616347 \n",
       "L 303.361051 300.958068 \n",
       "L 305.521389 298.909888 \n",
       "L 307.612038 294.351863 \n",
       "L 309.772375 293.613134 \n",
       "L 311.932712 288.749516 \n",
       "L 313.883984 286.584592 \n",
       "L 316.044321 285.411642 \n",
       "L 318.13497 284.897433 \n",
       "L 320.295308 284.989929 \n",
       "L 322.385956 285.472025 \n",
       "L 324.546294 282.373929 \n",
       "L 326.706631 278.790749 \n",
       "L 328.79728 280.186459 \n",
       "L 330.957617 282.377263 \n",
       "L 333.048266 279.259496 \n",
       "L 335.208603 280.622363 \n",
       "L 337.36894 280.673497 \n",
       "L 339.320213 277.821453 \n",
       "L 341.48055 277.47733 \n",
       "L 343.571199 277.963431 \n",
       "L 345.731536 278.700988 \n",
       "L 347.822185 278.327699 \n",
       "L 349.982522 277.174177 \n",
       "L 352.142859 276.457076 \n",
       "L 354.233508 277.766316 \n",
       "L 358.484494 277.723696 \n",
       "L 360.644831 281.888869 \n",
       "L 362.805169 282.875038 \n",
       "L 364.826129 279.246189 \n",
       "L 366.986466 279.431216 \n",
       "L 369.077115 277.518275 \n",
       "L 371.237453 277.077953 \n",
       "L 373.328101 278.539341 \n",
       "L 375.488439 281.424359 \n",
       "L 377.648776 277.910918 \n",
       "L 379.739425 279.491287 \n",
       "L 381.899762 278.55014 \n",
       "L 383.990411 281.595526 \n",
       "L 386.150748 281.151696 \n",
       "L 388.311085 279.693773 \n",
       "L 390.262358 277.64966 \n",
       "L 392.422695 276.543863 \n",
       "L 394.513344 277.157996 \n",
       "L 396.673681 273.137736 \n",
       "L 398.76433 274.978373 \n",
       "L 400.924667 272.797252 \n",
       "L 403.085004 269.374217 \n",
       "L 405.175653 269.974216 \n",
       "L 407.33599 268.72098 \n",
       "L 409.426639 265.839639 \n",
       "L 411.586976 264.348195 \n",
       "L 413.747314 261.738179 \n",
       "L 415.698586 257.561277 \n",
       "L 417.858923 255.493109 \n",
       "L 419.949572 256.933047 \n",
       "L 422.109909 255.78503 \n",
       "L 424.200558 253.582834 \n",
       "L 426.360895 252.146249 \n",
       "L 428.521233 249.621827 \n",
       "L 430.611881 244.112886 \n",
       "L 432.772219 243.376048 \n",
       "L 434.862868 245.598281 \n",
       "L 437.023205 264.624962 \n",
       "L 439.183542 258.085852 \n",
       "L 441.134814 256.742958 \n",
       "L 443.295151 248.67086 \n",
       "L 445.3858 249.933083 \n",
       "L 447.546138 233.738797 \n",
       "L 449.636786 235.92548 \n",
       "L 451.797124 240.258421 \n",
       "L 453.957461 239.484781 \n",
       "L 456.04811 235.769842 \n",
       "L 458.208447 226.969998 \n",
       "L 460.299096 217.062003 \n",
       "L 462.459433 211.60845 \n",
       "L 464.61977 217.453614 \n",
       "L 466.640731 217.725474 \n",
       "L 468.801068 210.269564 \n",
       "L 470.891717 207.305594 \n",
       "L 473.052054 208.265498 \n",
       "L 475.142703 201.86529 \n",
       "L 477.30304 203.814686 \n",
       "L 479.463377 202.27581 \n",
       "L 481.554026 200.560284 \n",
       "L 483.714364 199.012084 \n",
       "L 485.805012 201.805877 \n",
       "L 487.96535 201.59531 \n",
       "L 490.125687 206.629368 \n",
       "L 492.076959 204.736225 \n",
       "L 494.237296 206.10335 \n",
       "L 496.327945 210.889756 \n",
       "L 498.488283 217.669967 \n",
       "L 500.578931 218.040346 \n",
       "L 502.739269 220.01979 \n",
       "L 504.899606 220.343391 \n",
       "L 506.990255 219.51903 \n",
       "L 509.150592 225.299048 \n",
       "L 511.241241 229.832283 \n",
       "L 513.401578 232.198213 \n",
       "L 515.561915 238.281344 \n",
       "L 517.513188 238.012516 \n",
       "L 519.673525 233.690709 \n",
       "L 521.764174 235.428203 \n",
       "L 523.924511 238.3971 \n",
       "L 526.01516 242.35515 \n",
       "L 528.175497 242.538058 \n",
       "L 530.335834 245.164518 \n",
       "L 532.426483 248.051484 \n",
       "L 534.58682 249.088588 \n",
       "L 536.677469 243.4459 \n",
       "L 538.837806 244.394042 \n",
       "L 540.998144 249.517444 \n",
       "L 542.949416 243.709474 \n",
       "L 545.109753 239.410012 \n",
       "L 547.200402 242.141482 \n",
       "L 549.360739 240.542571 \n",
       "L 551.451388 244.071738 \n",
       "L 553.611725 247.387509 \n",
       "L 555.772062 249.049651 \n",
       "L 557.862711 248.055277 \n",
       "L 560.023049 250.703525 \n",
       "L 562.113698 251.766492 \n",
       "L 564.274035 250.495351 \n",
       "L 568.455333 250.604348 \n",
       "L 570.61567 247.525809 \n",
       "L 572.706319 252.021386 \n",
       "L 574.866656 250.880249 \n",
       "L 576.957305 253.867254 \n",
       "L 579.117642 253.929401 \n",
       "L 581.277979 251.591701 \n",
       "L 583.368628 254.021781 \n",
       "L 585.528965 255.976957 \n",
       "L 587.619614 257.445292 \n",
       "L 591.940289 274.581746 \n",
       "L 593.891561 270.597675 \n",
       "L 596.051898 265.821256 \n",
       "L 598.142547 268.330138 \n",
       "L 600.302884 267.91183 \n",
       "L 602.393533 266.538288 \n",
       "L 604.55387 262.38622 \n",
       "L 606.714207 258.914983 \n",
       "L 608.804856 259.723013 \n",
       "L 610.965194 263.023341 \n",
       "L 613.055842 253.146333 \n",
       "L 615.21618 249.047693 \n",
       "L 617.376517 249.52602 \n",
       "L 619.327789 246.108142 \n",
       "L 621.488126 241.731731 \n",
       "L 623.578775 250.839966 \n",
       "L 625.739113 244.814971 \n",
       "L 627.829761 247.200868 \n",
       "L 629.990099 239.883605 \n",
       "L 632.150436 240.995984 \n",
       "L 634.241085 243.833816 \n",
       "L 636.401422 236.19275 \n",
       "L 638.492071 235.181733 \n",
       "L 640.652408 237.758479 \n",
       "L 642.812745 236.34677 \n",
       "L 644.764018 231.61777 \n",
       "L 646.924355 233.898209 \n",
       "L 649.015004 236.865968 \n",
       "L 651.175341 232.632826 \n",
       "L 653.26599 230.580617 \n",
       "L 655.426327 233.018926 \n",
       "L 657.586664 231.895161 \n",
       "L 659.677313 229.929777 \n",
       "L 661.83765 228.412067 \n",
       "L 663.928299 223.389426 \n",
       "L 666.088636 223.81533 \n",
       "L 666.088636 223.81533 \n",
       "\" clip-path=\"url(#p686369a5c2)\" style=\"fill: none; stroke: #ff0000; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_31\">\n",
       "    <path d=\"M 57.361364 322.036695 \n",
       "L 59.382324 324.10015 \n",
       "L 61.542661 323.957825 \n",
       "L 65.793648 323.112774 \n",
       "L 67.884296 320.865166 \n",
       "L 70.044634 320.258786 \n",
       "L 72.204971 321.345682 \n",
       "L 74.29562 322.175152 \n",
       "L 76.455957 322.038378 \n",
       "L 78.546606 321.429577 \n",
       "L 80.706943 320.672885 \n",
       "L 84.818553 318.438743 \n",
       "L 86.97889 318.748726 \n",
       "L 89.069539 319.749899 \n",
       "L 91.229876 321.087172 \n",
       "L 93.320525 320.461104 \n",
       "L 95.480862 320.464135 \n",
       "L 97.641199 320.713262 \n",
       "L 99.731848 319.644899 \n",
       "L 101.892185 319.26574 \n",
       "L 103.982834 318.689928 \n",
       "L 106.143171 317.744797 \n",
       "L 108.303509 317.497937 \n",
       "L 110.254781 316.948726 \n",
       "L 112.415118 317.291964 \n",
       "L 114.505767 317.949736 \n",
       "L 116.666104 318.879059 \n",
       "L 118.756753 318.101825 \n",
       "L 120.91709 318.0609 \n",
       "L 123.077428 317.761894 \n",
       "L 125.168076 317.649856 \n",
       "L 127.328414 317.870377 \n",
       "L 129.419063 317.310911 \n",
       "L 131.5794 317.120202 \n",
       "L 133.739737 316.3039 \n",
       "L 135.691009 316.400603 \n",
       "L 137.851346 315.560707 \n",
       "L 139.941995 313.86225 \n",
       "L 142.102333 314.108541 \n",
       "L 144.192981 312.788294 \n",
       "L 146.353319 311.748008 \n",
       "L 148.513656 312.045617 \n",
       "L 150.604305 311.985016 \n",
       "L 152.764642 308.209583 \n",
       "L 154.855291 307.571462 \n",
       "L 157.015628 302.968926 \n",
       "L 159.175965 303.365447 \n",
       "L 161.196926 304.336082 \n",
       "L 163.357263 303.110999 \n",
       "L 165.447912 300.128783 \n",
       "L 167.608249 300.598195 \n",
       "L 169.698898 298.105746 \n",
       "L 171.859235 297.634292 \n",
       "L 174.019573 295.111248 \n",
       "L 176.110221 293.431735 \n",
       "L 178.270559 292.055993 \n",
       "L 180.361208 293.741333 \n",
       "L 182.521545 291.063024 \n",
       "L 186.633154 288.125512 \n",
       "L 188.793491 285.223049 \n",
       "L 190.88414 282.770788 \n",
       "L 193.044478 286.353406 \n",
       "L 195.135126 283.138073 \n",
       "L 197.295464 278.551609 \n",
       "L 199.455801 280.622733 \n",
       "L 201.54645 279.755105 \n",
       "L 203.706787 279.361551 \n",
       "L 205.797436 279.952828 \n",
       "L 207.957773 277.357143 \n",
       "L 210.11811 276.883686 \n",
       "L 212.069383 276.603269 \n",
       "L 214.22972 275.663026 \n",
       "L 216.320369 276.839507 \n",
       "L 218.480706 279.313939 \n",
       "L 220.571355 277.051797 \n",
       "L 222.731692 277.0086 \n",
       "L 224.892029 277.758888 \n",
       "L 226.982678 279.274729 \n",
       "L 229.143015 273.239786 \n",
       "L 231.233664 266.946736 \n",
       "L 233.394001 264.52481 \n",
       "L 235.554339 265.414046 \n",
       "L 237.505611 268.566421 \n",
       "L 239.665948 270.967189 \n",
       "L 241.756597 277.657684 \n",
       "L 243.916934 275.522014 \n",
       "L 246.007583 266.432382 \n",
       "L 248.16792 266.225682 \n",
       "L 252.418906 256.805118 \n",
       "L 254.579244 247.888131 \n",
       "L 256.669893 247.48838 \n",
       "L 258.83023 249.531097 \n",
       "L 263.011528 248.781196 \n",
       "L 265.171865 249.091936 \n",
       "L 267.262514 241.337736 \n",
       "L 269.422851 242.852635 \n",
       "L 271.5135 243.213336 \n",
       "L 273.673837 242.290028 \n",
       "L 275.834174 234.623561 \n",
       "L 277.924823 239.690262 \n",
       "L 282.175809 231.005583 \n",
       "L 284.336146 230.781625 \n",
       "L 286.496484 224.594285 \n",
       "L 288.447756 228.980169 \n",
       "L 290.608093 229.316006 \n",
       "L 292.698742 225.812753 \n",
       "L 294.859079 228.143286 \n",
       "L 296.949728 222.920812 \n",
       "L 299.110065 232.461148 \n",
       "L 301.270403 229.761016 \n",
       "L 303.361051 224.531863 \n",
       "L 305.521389 226.437823 \n",
       "L 307.612038 229.381107 \n",
       "L 309.772375 227.143665 \n",
       "L 311.932712 223.612706 \n",
       "L 313.883984 226.873983 \n",
       "L 316.044321 225.941851 \n",
       "L 318.13497 226.029743 \n",
       "L 320.295308 225.045821 \n",
       "L 322.385956 219.873156 \n",
       "L 324.546294 220.263888 \n",
       "L 326.706631 227.732718 \n",
       "L 328.79728 231.658812 \n",
       "L 330.957617 230.459783 \n",
       "L 333.048266 231.352629 \n",
       "L 335.208603 227.063403 \n",
       "L 337.36894 220.897305 \n",
       "L 339.320213 228.35843 \n",
       "L 341.48055 226.05444 \n",
       "L 343.571199 223.501342 \n",
       "L 345.731536 222.25253 \n",
       "L 347.822185 222.22195 \n",
       "L 349.982522 224.699435 \n",
       "L 352.142859 223.849283 \n",
       "L 354.233508 218.295132 \n",
       "L 356.393845 217.024686 \n",
       "L 358.484494 218.795848 \n",
       "L 360.644831 205.055971 \n",
       "L 362.805169 199.542075 \n",
       "L 364.826129 203.932935 \n",
       "L 366.986466 201.091763 \n",
       "L 369.077115 200.024992 \n",
       "L 371.237453 201.490709 \n",
       "L 373.328101 196.564833 \n",
       "L 375.488439 191.122866 \n",
       "L 377.648776 192.989916 \n",
       "L 379.739425 192.945643 \n",
       "L 381.899762 190.992508 \n",
       "L 383.990411 181.303209 \n",
       "L 386.150748 182.010533 \n",
       "L 388.311085 181.896222 \n",
       "L 390.262358 184.261001 \n",
       "L 392.422695 185.289231 \n",
       "L 394.513344 182.914647 \n",
       "L 396.673681 189.843056 \n",
       "L 398.76433 184.008749 \n",
       "L 400.924667 189.876852 \n",
       "L 403.085004 188.158411 \n",
       "L 405.175653 192.212143 \n",
       "L 407.33599 183.832007 \n",
       "L 409.426639 188.484896 \n",
       "L 411.586976 182.764988 \n",
       "L 413.747314 193.22265 \n",
       "L 415.698586 195.414955 \n",
       "L 417.858923 185.845621 \n",
       "L 419.949572 182.736511 \n",
       "L 422.109909 188.116757 \n",
       "L 424.200558 191.726639 \n",
       "L 426.360895 186.664736 \n",
       "L 428.521233 192.843828 \n",
       "L 430.611881 197.262245 \n",
       "L 432.772219 193.47061 \n",
       "L 434.862868 185.332677 \n",
       "L 437.023205 159.663775 \n",
       "L 439.183542 166.310072 \n",
       "L 441.134814 173.582095 \n",
       "L 443.295151 183.131701 \n",
       "L 445.3858 185.650661 \n",
       "L 447.546138 202.505661 \n",
       "L 451.797124 177.066846 \n",
       "L 453.957461 170.580273 \n",
       "L 456.04811 166.356221 \n",
       "L 458.208447 181.059825 \n",
       "L 460.299096 180.312385 \n",
       "L 462.459433 175.758514 \n",
       "L 464.61977 163.953721 \n",
       "L 466.640731 162.36775 \n",
       "L 468.801068 163.435829 \n",
       "L 470.891717 161.029985 \n",
       "L 473.052054 156.724687 \n",
       "L 475.142703 158.852762 \n",
       "L 477.30304 148.607411 \n",
       "L 479.463377 148.931745 \n",
       "L 481.554026 146.796736 \n",
       "L 483.714364 148.703235 \n",
       "L 485.805012 147.068229 \n",
       "L 487.96535 147.235009 \n",
       "L 490.125687 144.039742 \n",
       "L 492.076959 143.85361 \n",
       "L 494.237296 137.437734 \n",
       "L 498.488283 114.232831 \n",
       "L 500.578931 109.816205 \n",
       "L 502.739269 102.621244 \n",
       "L 506.990255 110.549994 \n",
       "L 509.150592 101.776974 \n",
       "L 511.241241 94.94622 \n",
       "L 513.401578 89.995563 \n",
       "L 515.561915 66.872843 \n",
       "L 517.513188 71.237298 \n",
       "L 519.673525 90.930054 \n",
       "L 521.764174 93.053696 \n",
       "L 523.924511 87.620658 \n",
       "L 526.01516 77.481117 \n",
       "L 528.175497 68.330142 \n",
       "L 530.335834 66.267688 \n",
       "L 532.426483 60.424531 \n",
       "L 534.58682 49.19639 \n",
       "L 536.677469 58.442821 \n",
       "L 538.837806 55.350081 \n",
       "L 540.998144 43.117352 \n",
       "L 542.949416 72.83901 \n",
       "L 545.109753 84.012667 \n",
       "L 547.200402 75.893602 \n",
       "L 549.360739 75.32346 \n",
       "L 551.451388 65.529506 \n",
       "L 553.611725 63.347375 \n",
       "L 555.772062 76.822987 \n",
       "L 557.862711 72.319879 \n",
       "L 560.023049 72.00209 \n",
       "L 562.113698 69.022516 \n",
       "L 564.274035 70.676474 \n",
       "L 566.434372 83.417501 \n",
       "L 568.455333 98.986497 \n",
       "L 570.61567 82.712945 \n",
       "L 572.706319 84.499853 \n",
       "L 574.866656 88.275572 \n",
       "L 576.957305 96.27579 \n",
       "L 579.117642 99.445844 \n",
       "L 581.277979 89.672098 \n",
       "L 583.368628 87.726573 \n",
       "L 585.528965 88.369247 \n",
       "L 587.619614 78.187097 \n",
       "L 589.779951 92.837118 \n",
       "L 591.940289 87.770776 \n",
       "L 593.891561 72.1258 \n",
       "L 596.051898 59.343947 \n",
       "L 598.142547 79.222291 \n",
       "L 600.302884 92.622364 \n",
       "L 602.393533 107.11891 \n",
       "L 604.55387 119.21806 \n",
       "L 606.714207 109.107288 \n",
       "L 608.804856 93.5043 \n",
       "L 610.965194 106.186664 \n",
       "L 613.055842 115.982539 \n",
       "L 617.376517 85.02311 \n",
       "L 619.327789 83.254971 \n",
       "L 621.488126 72.080648 \n",
       "L 623.578775 51.536758 \n",
       "L 625.739113 62.000389 \n",
       "L 627.829761 71.344936 \n",
       "L 629.990099 77.901176 \n",
       "L 632.150436 67.67758 \n",
       "L 634.241085 58.810012 \n",
       "L 636.401422 72.14974 \n",
       "L 638.492071 61.476786 \n",
       "L 640.652408 59.406449 \n",
       "L 642.812745 54.751624 \n",
       "L 644.764018 53.328942 \n",
       "L 646.924355 57.34482 \n",
       "L 649.015004 42.531302 \n",
       "L 651.175341 45.278883 \n",
       "L 653.26599 39.35994 \n",
       "L 655.426327 29.061905 \n",
       "L 657.586664 26.532232 \n",
       "L 659.677313 22.32 \n",
       "L 661.83765 33.602641 \n",
       "L 663.928299 37.753089 \n",
       "L 666.088636 30.630886 \n",
       "L 666.088636 30.630886 \n",
       "\" clip-path=\"url(#p686369a5c2)\" style=\"fill: none; stroke: #0000ff; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 26.925 339.84 \n",
       "L 26.925 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 696.525 339.84 \n",
       "L 696.525 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 26.925 339.84 \n",
       "L 696.525 339.84 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 26.925 7.2 \n",
       "L 696.525 7.2 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 33.925 44.55625 \n",
       "L 87.7625 44.55625 \n",
       "Q 89.7625 44.55625 89.7625 42.55625 \n",
       "L 89.7625 14.2 \n",
       "Q 89.7625 12.2 87.7625 12.2 \n",
       "L 33.925 12.2 \n",
       "Q 31.925 12.2 31.925 14.2 \n",
       "L 31.925 42.55625 \n",
       "Q 31.925 44.55625 33.925 44.55625 \n",
       "z\n",
       "\" style=\"fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_32\">\n",
       "     <path d=\"M 35.925 20.298437 \n",
       "L 45.925 20.298437 \n",
       "L 55.925 20.298437 \n",
       "\" style=\"fill: none; stroke: #ff0000; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    </g>\n",
       "    <g id=\"text_30\">\n",
       "     <!-- SMB -->\n",
       "     <g transform=\"translate(63.925 23.798437) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-53\" d=\"M 3425 4513 \n",
       "L 3425 3897 \n",
       "Q 3066 4069 2747 4153 \n",
       "Q 2428 4238 2131 4238 \n",
       "Q 1616 4238 1336 4038 \n",
       "Q 1056 3838 1056 3469 \n",
       "Q 1056 3159 1242 3001 \n",
       "Q 1428 2844 1947 2747 \n",
       "L 2328 2669 \n",
       "Q 3034 2534 3370 2195 \n",
       "Q 3706 1856 3706 1288 \n",
       "Q 3706 609 3251 259 \n",
       "Q 2797 -91 1919 -91 \n",
       "Q 1588 -91 1214 -16 \n",
       "Q 841 59 441 206 \n",
       "L 441 856 \n",
       "Q 825 641 1194 531 \n",
       "Q 1563 422 1919 422 \n",
       "Q 2459 422 2753 634 \n",
       "Q 3047 847 3047 1241 \n",
       "Q 3047 1584 2836 1778 \n",
       "Q 2625 1972 2144 2069 \n",
       "L 1759 2144 \n",
       "Q 1053 2284 737 2584 \n",
       "Q 422 2884 422 3419 \n",
       "Q 422 4038 858 4394 \n",
       "Q 1294 4750 2059 4750 \n",
       "Q 2388 4750 2728 4690 \n",
       "Q 3069 4631 3425 4513 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-4d\" d=\"M 628 4666 \n",
       "L 1569 4666 \n",
       "L 2759 1491 \n",
       "L 3956 4666 \n",
       "L 4897 4666 \n",
       "L 4897 0 \n",
       "L 4281 0 \n",
       "L 4281 4097 \n",
       "L 3078 897 \n",
       "L 2444 897 \n",
       "L 1241 4097 \n",
       "L 1241 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-42\" d=\"M 1259 2228 \n",
       "L 1259 519 \n",
       "L 2272 519 \n",
       "Q 2781 519 3026 730 \n",
       "Q 3272 941 3272 1375 \n",
       "Q 3272 1813 3026 2020 \n",
       "Q 2781 2228 2272 2228 \n",
       "L 1259 2228 \n",
       "z\n",
       "M 1259 4147 \n",
       "L 1259 2741 \n",
       "L 2194 2741 \n",
       "Q 2656 2741 2882 2914 \n",
       "Q 3109 3088 3109 3444 \n",
       "Q 3109 3797 2882 3972 \n",
       "Q 2656 4147 2194 4147 \n",
       "L 1259 4147 \n",
       "z\n",
       "M 628 4666 \n",
       "L 2241 4666 \n",
       "Q 2963 4666 3353 4366 \n",
       "Q 3744 4066 3744 3513 \n",
       "Q 3744 3084 3544 2831 \n",
       "Q 3344 2578 2956 2516 \n",
       "Q 3422 2416 3680 2098 \n",
       "Q 3938 1781 3938 1306 \n",
       "Q 3938 681 3513 340 \n",
       "Q 3088 0 2303 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-53\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-4d\" x=\"63.476562\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-42\" x=\"149.755859\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_33\">\n",
       "     <path d=\"M 35.925 34.976562 \n",
       "L 45.925 34.976562 \n",
       "L 55.925 34.976562 \n",
       "\" style=\"fill: none; stroke: #0000ff; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    </g>\n",
       "    <g id=\"text_31\">\n",
       "     <!-- HML -->\n",
       "     <g transform=\"translate(63.925 38.476562) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-48\" d=\"M 628 4666 \n",
       "L 1259 4666 \n",
       "L 1259 2753 \n",
       "L 3553 2753 \n",
       "L 3553 4666 \n",
       "L 4184 4666 \n",
       "L 4184 0 \n",
       "L 3553 0 \n",
       "L 3553 2222 \n",
       "L 1259 2222 \n",
       "L 1259 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-4c\" d=\"M 628 4666 \n",
       "L 1259 4666 \n",
       "L 1259 531 \n",
       "L 3531 531 \n",
       "L 3531 0 \n",
       "L 628 0 \n",
       "L 628 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-48\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-4d\" x=\"75.195312\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-4c\" x=\"161.474609\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p686369a5c2\">\n",
       "   <rect x=\"26.925\" y=\"7.2\" width=\"669.6\" height=\"332.64\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 1200x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(12,6))\n",
    "\n",
    "factors['SMBprice'] = (factors['SMB'] + 1).cumprod()\n",
    "factors['HMLprice'] = (factors['HML'] + 1).cumprod()\n",
    "\n",
    "plt.plot(factors['SMBprice'],color='red',label='SMB')\n",
    "plt.plot(factors['HMLprice'],color='blue',label='HML')\n",
    "plt.legend(loc='upper left')\n",
    "\n",
    "xticks = factors.index[::12]\n",
    "xtick_labels = [label.year for label in xticks]\n",
    "plt.xticks(xticks, xtick_labels, rotation=90)\n",
    "\n",
    "plt.show();"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 最大回测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum Drawdown: -0.49187624458364076\n"
     ]
    }
   ],
   "source": [
    "# 计算累积收益率\n",
    "factors['cumulative_return'] = (1 + factors['SMB']).cumprod()\n",
    "\n",
    "# 计算滚动最大值\n",
    "factors['rolling_max'] = factors['cumulative_return'].cummax()\n",
    "\n",
    "# 计算回撤\n",
    "factors['drawdown'] = factors['cumulative_return'] / factors['rolling_max'] - 1\n",
    "\n",
    "# 计算最大回撤\n",
    "max_drawdown = factors['drawdown'].min()\n",
    "print(f\"Maximum Drawdown: {max_drawdown}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum Drawdown: -0.49187624458364076\n",
      "Maximum Drawdown Start Date: 2016-10-31 00:00:00\n",
      "Maximum Drawdown End Date: 2021-01-31 00:00:00\n"
     ]
    }
   ],
   "source": [
    "# 找出最大回撤的时间\n",
    "max_drawdown_end = factors['drawdown'].idxmin() # 返回 Series 中最小值的索引\n",
    "max_drawdown_start = factors.loc[:max_drawdown_end, 'cumulative_return'].idxmax() # 这部分代码选择了从数据开始到 max_drawdown_end 时间点之间的所有累积收益率\n",
    "\n",
    "print(f\"Maximum Drawdown: {max_drawdown}\")\n",
    "print(f\"Maximum Drawdown Start Date: {max_drawdown_start}\")\n",
    "print(f\"Maximum Drawdown End Date: {max_drawdown_end}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum Drawdown: -0.24585871064760811\n"
     ]
    }
   ],
   "source": [
    "# 计算累积收益率\n",
    "factors['cumulative_return'] = (1 + factors['HML']).cumprod()\n",
    "\n",
    "# 计算滚动最大值\n",
    "factors['rolling_max'] = factors['cumulative_return'].cummax()\n",
    "\n",
    "# 计算回撤\n",
    "factors['drawdown'] = factors['cumulative_return'] / factors['rolling_max'] - 1\n",
    "\n",
    "# 计算最大回撤\n",
    "max_drawdown = factors['drawdown'].min()\n",
    "print(f\"Maximum Drawdown: {max_drawdown}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum Drawdown: -0.24585871064760811\n",
      "Maximum Drawdown Start Date: 2019-01-31 00:00:00\n",
      "Maximum Drawdown End Date: 2021-07-31 00:00:00\n"
     ]
    }
   ],
   "source": [
    "# 找出最大回撤的时间\n",
    "max_drawdown_end = factors['drawdown'].idxmin() # 返回 Series 中最小值的索引\n",
    "max_drawdown_start = factors.loc[:max_drawdown_end, 'cumulative_return'].idxmax() # 这部分代码选择了从数据开始到 max_drawdown_end 时间点之间的所有累积收益率\n",
    "\n",
    "print(f\"Maximum Drawdown: {max_drawdown}\")\n",
    "print(f\"Maximum Drawdown Start Date: {max_drawdown_start}\")\n",
    "print(f\"Maximum Drawdown End Date: {max_drawdown_end}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "法玛三因子模型在中国落地研究主要通过以下几个步骤进行：\n",
    "1. **模型选择与数据采集**：\n",
    "   - 选择CAPM模型和Fama-French三因子模型作为基础。数据采集方面，会选取中国A股市场的数据\n",
    "2. **因子定义与构建组合**：\n",
    "   - 在Fama-French三因子模型中，市场因子（MKT）、规模因子（SMB）和账面市值比因子（HML）被用作解释变量。研究者会根据市值大小和账面市值比将股票分成不同的组合，如小盘股(S)和大盘股(B)，以及高账面市值比(H)、中账面市值比(M)和低账面市值比(L)。\n",
    "3. **实证分析**：\n",
    "   - 对选定的股票数据进行实证分析，检验模型在中国股票市场上的适用性。研究者会计算市场因子、规模因子和账面市值比因子的收益率，并进行多元线性回归分析，以确定各因子对股票收益的影响程度。\n",
    "4. **模型比较与适用性检验**：\n",
    "   - 比较CAPM模型和Fama-French三因子模型的效果，分析哪个模型在中国股票市场上的适用价值更高。结果通常表明，Fama-French三因子模型由于包含更多的因子，其解释力度优于CAPM模型。\n",
    "5. **考虑中国市场特殊性**：\n",
    "   - 考虑中国市场的特殊性，如交易制度、风险因素等，这些因素可能会影响模型的解释力度。研究发现，中国市场的一些特殊特征，如“小盘股效应”和“账面市值比效应”，在一定程度上影响了三因子模型的适用性。\n",
    "6. **政策建议与投资策略**：\n",
    "   - 结果可以为资本市场投资策略提供理论支持，促进投资股票、构建组合的理性思考，并对中国股票市场的运行特征有更深入的了解。\n",
    "通过上述步骤，评估法玛三因子模型在中国A股市场的适用性，并提出相应的投资策略和政策建议。\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
